Subject: bug#5653: 23.1; pdbtrack isn't parsing valid pdb output or creating an interactive debugging buffer (python.el)

From: Jeremy Whitlock <[email-masked]>
Date: Fri, 26 Feb 2010 14:09:42 -0700

Python debugging with gud-pdb appears to be broken.  There are actually two problems:

1) While debugging Python code in emacs I kept seeing "Traceback cue not found" errors popping up in the minibuffer.  After a good bit of googling, I found this:

https://bugs.launchpad.net/python-mode/+bug/505295

Once I applied this patch, those errors went away.  Here is the patch:

--- a/python.el	2010-02-26 13:47:13.000000000 -0700
+++ b/python.el	2010-02-26 13:47:38.000000000 -0700
@@ -575,7 +575,7 @@
(defvar python-pdbtrack-is-tracking-p nil)

(defconst python-pdbtrack-stack-entry-regexp
-  "^> \\(.*\\)(\\([0-9]+\\))\\([?a-zA-Z0-9_]+\\)()"
+  "^> \\(.*\\)(\\([0-9]+\\))\\([?a-zA-Z0-9_<>]+\\)()"
   "Regular expression pdbtrack uses to find a stack trace entry.")

(defconst python-pdbtrack-input-prompt "\n[(<]*[Pp]db[>)]+ "

2) Debugging Python in emacs doesn't work with "M-x pdb".  If I invoke pdb using "M-x pdb", I end up at a buffer that says:

Current directory is <pwd>

No matter what I do, the buffer never updates or creates an interactive pdb shell until I kill the debugging session by running to the end of the script or killing the debugger session.  It's at this point I see exactly what I would had expected to see in the first place, the pdb interactive session and its output.  The only way I can debug Python in emacs is to open a shell, invoke "python -m pdb <file>".  The good news is python.el has support to automatically link the shell's pdb output to an editor pointing to the file being debugged.

In the end, with the patch applied, I can debug by manually invoking pdb from a shell buffer (M-x shell) but even with that patch applied, pdb (M-x pdb) support fails to work as described earlier.  I think issue #1 can be fixed with the inline patch, as it does make it so you can debug Python in emacs where you cannot without the patch being applied.  Please let me know if there is more information I can provide.

Environment Information
---------------------------------
Emacs: 23.1.1 (http://emacsformacosx.com/)
OS: Mac OS X 10.6.2 (Snow Leopard)
Python: 2.6.1

In GNU Emacs 23.1.1 (i386-apple-darwin9.8.0, NS apple-appkit-949.54)
of 2009-08-16 on black.local
Windowing system distributor `Apple', version 10.3.1038
configured using `configure  '--with-ns''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  value of $XMODIFIERS: nil
  locale-coding-system: nil
  default-enable-multibyte-characters: t

Major mode: Fundamental

Minor modes in effect:
  show-paren-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x r e p o r t - e m a <tab> <return>

Recent messages:
Loading /Users/jwhitlock/.emacs.d/color-theme/themes/color-theme-example.el (source)...done
Loading /Users/jwhitlock/.emacs.d/color-theme/themes/color-theme-library.el (source)...done
Loading /Users/jwhitlock/.emacs.frameg...done
For information about GNU Emacs and the GNU system, type C-h C-a.

Jeremy Whitlock <[email-masked]>
http://www.thoughtspark.org