[Python-Dev] short-circuiting runtime errors/exceptions in python debugger.

Steve Dower steve.dower at python.org
Mon Oct 29 23:40:36 EDT 2018

On 29Oct2018 1709, Nathaniel Smith wrote:
> I also wonder if it would be useful to give pdb the ability to break
> when an exception is *raised*, rather than when it's caught?

This is basically the first feature I implemented as an intern at
Microsoft back in 2011 :) (for Visual Studio's Python debugger)

It should be in the ptvsd and PyDev.Debugger packages, so any IDEs that
use those for debugging will support it (though it's not my
implementation any more, as far as I know).

Specifically, breaking on an exception is trivial, but filtering out the
cases that have handlers on the stack is nearly impossible. We got close
enough with looking at the AST of each caller that we didn't try any
harder than that. If you know *where* you're expecting the exception,
you could even filter on line number and then break when that line is on
the stack but before unwinding.


More information about the Python-Dev mailing list