Is it possible to automatically break into the debugger when a exception is thrown?

前端 未结 6 545
栀梦
栀梦 2021-02-07 06:00

If ones catches an exception outside of the function it is originally thrown, ones loses access to the local stack. As a result one cannot inspect the values of the variables th

6条回答
  •  礼貌的吻别
    2021-02-07 06:32

    You don't want to break on every exception; idiomatic Python code uses exceptions heavily (EAFP) so you'd be continually breaking in unrelated code.

    Instead, use pdb post-mortem: import pdb; pdb.pm(). This uses sys.last_traceback to inspect the stack including the locals at the throw point.

提交回复
热议问题