feature proposal, debug on exception

Paul Rubin http
Tue May 20 20:59:07 EDT 2008


There's an occasional question here about how to get python to launch
pdb on encountering an uncaught exception.  The answer is to look in
some ASPN recipe and do some weird magic.  I guess that works, but
it's another thing to remember or keep looking up when the occasion
arises (some program crashes unexpectedly).  I find myself manually
adding tracing instead, finding out that I did it wrong and having to
re-launch a long-running program, etc.

I'd like to propose that debug-on-exception be made into a standard
feature that is easy to enable, e.g. with a command line option
or with a simple pdb call immediately after the import:

  import pdb
  pdb.debug_on_exception(True)
  ...

Would there be big obstacles to this?  It would have saved me
considerable hassle on a number of occasions.  I'm constantly
processing large data sets that will munch along happily for hours and
hours before hitting some unanticipated condition in the data, and it
would be great to trap immediately rather than have to analyze the
resulting stack dump and restart.



More information about the Python-list mailing list