feature proposal, debug on exception

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Rubin

    feature proposal, debug on exception

    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_ex ception(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.
  • Simon Forman

    #2
    Re: feature proposal, debug on exception

    On May 20, 5:59 pm, Paul Rubin <http://phr...@NOSPAM.i nvalidwrote:
    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_ex ception(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.

    This is not exactly an answer to your proposal, I know, but FWIW
    Ipython has exactly this capability.

    Regards,
    ~S

    Comment

    • alex23

      #3
      Re: feature proposal, debug on exception

      On May 21, 10:59 am, Paul Rubin <http://phr...@NOSPAM.i nvalidwrote:
      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:
      Forgive me if I've missed your point, but it seems you can already do
      this:

      pdb.py can also be invoked as a script to debug other scripts.
      For example:

      python -m pdb myscript.py

      When invoked as a script, pdb will automatically enter post-mortem
      debugging if the program being debugged exits abnormally. After
      post-mortem debugging (or after normal exit of the program), pdb
      will restart the program. Automatic restarting preserves pdb's
      state (such as breakpoints) and in most cases is more useful than
      quitting the debugger upon program's exit. New in version 2.4:
      Restarting post-mortem behavior added.

      Source code: Lib/pdb.py The module pdb defines an interactive source code debugger for Python programs. It supports setting (conditional) breakpoints and single stepping at the source line level, i...

      Comment

      • Ville M. Vainio

        #4
        Re: feature proposal, debug on exception

        Simon Forman <sajmikins@gmai l.comwrites:
        This is not exactly an answer to your proposal, I know, but FWIW
        Ipython has exactly this capability.
        Yes.

        When you %run a scripts and get exception, you can launch post-mortem
        pdb on it by typing %debug.

        Comment

        Working...