all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Andreas Politz <politza@fh-trier.de>
Cc: 11679@debbugs.gnu.org
Subject: bug#11679: 24.1.50; gud/pdb3 hangs in lines with list comprehension
Date: Mon, 9 Sep 2019 04:38:05 +0200	[thread overview]
Message-ID: <CADwFkm=vOuLZHj=eMtBBe4dDFpEnxDGVRj-iHN8OvYLMvCRhuw@mail.gmail.com> (raw)
In-Reply-To: <874nqhvvte.fsf@fh-trier.de>

[-- Attachment #1: Type: text/plain, Size: 2633 bytes --]

tags 11679 fixed
close 11679 27.1
quit

Andreas Politz <politza@fh-trier.de> writes:

> For list comprehensions pdb3 outputs a line like this.
>
>> FILE(LINE)<listcomp>()
>
> But the `listcomp' token is not captured by the `gud-pdb-marker-regexp',
> resulting in pdb appearing to be hanging.  (This may be python2/3
> related.)
>
> diff -c -L /usr/share/emacs/24.1.50/lisp/progmodes/gud.el.gz -L \#\<buffer\ gud.el.gz\> /tmp/jka-com19603ZkZ /tmp/buffer-content-19603z4l
> *** /usr/share/emacs/24.1.50/lisp/progmodes/gud.el.gz
> --- #<buffer gud.el.gz>
> ***************
> *** 1567,1573 ****
>   ;; Last group is for return value, e.g. "> test.py(2)foo()->None"
>   ;; Either file or function name may be omitted: "> <string>(0)?()"
>   (defvar gud-pdb-marker-regexp
> !   "^> \\([-a-zA-Z0-9_/.:\\]*\\|<string>\\)(\\([0-9]+\\))\\([a-zA-Z0-9_]*\\|\\?\\|<module>\\)()\\(->[^\n\r]*\\)?[\n\r]")
>
>   (defvar gud-pdb-marker-regexp-file-group 1)
>   (defvar gud-pdb-marker-regexp-line-group 2)
> --- 1567,1573 ----
>   ;; Last group is for return value, e.g. "> test.py(2)foo()->None"
>   ;; Either file or function name may be omitted: "> <string>(0)?()"
>   (defvar gud-pdb-marker-regexp
> !   "^> \\([-a-zA-Z0-9_/.:\\]*\\|<string>\\)(\\([0-9]+\\))\\([a-zA-Z0-9_]*\\|\\?\\|<\\(?:module\\|listcomp\\)>\\)()\\(->[^\n\r]*\\)?[\n\r]")
>
>   (defvar gud-pdb-marker-regexp-file-group 1)
>   (defvar gud-pdb-marker-regexp-line-group 2)
>
> Diff finished.  Tue Jun 12 09:19:31 2012

I can reproduce this issue on current master, and it is indeed related
to the new code object names for anonymous objects in Python 3.

However, the fix you suggested was not complete, since it lacked
support for other common code objects.  I've therefore installed a
slightly different patch on master (see attached).

You could use the following Python 3 code to verify this fix:

# lambda
(lambda x: x + 1)(2)
# setcomp -- set comprehension
{s for s in [1, 2]}
# dictcomp -- dict comprehension
dict1 = {'a': 1, 'b': 2}
dict1_cond = {k:v for (k,v) in dict1.items() if v>2}
# listcomp -- list comprehension
[x*x for x in range(0,2)]
# genexpr -- generator expression
(x for x in range(5))
tuple(range(5))

Save the above as e.g. foo.py and run:

    M-x pdb RET python3 -m pdb foo.py RET

Then step through this to see output like this:

> /Users/skangas/wip/emacs/lisp/foo.py(7)<dictcomp>()
[...]
> /Users/skangas/wip/emacs/lisp/foo.py(11)<genexpr>()
[etc.]

AFAICT, the list I've installed is exhaustive, but if I've missed
something I'm sure someone will report a new bug report.  I'm
therefore closing this bug report as fixed.

Best regards,
Stefan Kangas

[-- Attachment #2: 0001-Match-Python-3-code-object-names-in-M-x-pdb.patch --]
[-- Type: application/octet-stream, Size: 1150 bytes --]

From 4042dad139d922723aabcfaef5662db8204fb355 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Mon, 9 Sep 2019 04:14:50 +0200
Subject: [PATCH] Match Python 3 code object names in "M-x pdb"

* lisp/progmodes/gud.el (gud-pdb-marker-regexp): Match Python 3 code
object names.  (Bug#11679)
---
 lisp/progmodes/gud.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 30d4b19911..235546ef2e 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -1610,7 +1610,9 @@ gud-pdb-history
 ;; characters we match in the file name shown in the prompt.
 ;; (Of course, this matches the "<string>" case too.)
 (defvar gud-pdb-marker-regexp
-  "^> \\([[:graph:] \\]*\\)(\\([0-9]+\\))\\([a-zA-Z0-9_]*\\|\\?\\|<module>\\)()\\(->[^\n\r]*\\)?[\n\r]")
+  (concat "^> \\([[:graph:] \\]*\\)(\\([0-9]+\\))\\([a-zA-Z0-9_]*\\|\\?\\|"
+          "<\\(?:module\\|listcomp\\|dictcomp\\|setcomp\\|genexpr\\|lambda\\|\\)>"
+          "\\)()\\(->[^\n\r]*\\)?[\n\r]"))
 
 (defvar gud-pdb-marker-regexp-file-group 1)
 (defvar gud-pdb-marker-regexp-line-group 2)
-- 
2.23.0


      parent reply	other threads:[~2019-09-09  2:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-12  7:22 bug#11679: 24.1.50; gud/pdb3 hangs in lines with list comprehension Andreas Politz
     [not found] ` <handler.11679.B.133948593625855.ack@debbugs.gnu.org>
2012-06-12  9:18   ` bug#11679: Acknowledgement (24.1.50; gud/pdb3 hangs in lines with list comprehension) Andreas Politz, INF|INF-I
2019-09-09  2:38 ` Stefan Kangas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkm=vOuLZHj=eMtBBe4dDFpEnxDGVRj-iHN8OvYLMvCRhuw@mail.gmail.com' \
    --to=stefan@marxist.se \
    --cc=11679@debbugs.gnu.org \
    --cc=politza@fh-trier.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.