Reputation: 4460
Is there a way to set a dynamic breakpoint***, suspend on exception, in pdb?
***dynamic in the sense of not tied to any line number
In pycharm (pydev), this is possible and is a nice feature, but often times, I have to use pdb due to limitations of the pycharm debugger (no jump functionality and/or the machine doesn't have pycharm).
Upvotes: 6
Views: 3408
Reputation: 69914
You're looking for postmortem
mode:
try:
code_that_may_raise_exception()
except Exception:
import pdb; pdb.post_mortem()
This will break on exception and drop you into a debugger right where it is being raised from
Upvotes: 7