Python - start interactive debugger when exception would be otherwise thrown

后端 未结 4 1171
-上瘾入骨i
-上瘾入骨i 2021-02-04 03:16

Is there any way to make a python program start an interactive debugger, like what import pdb; pdb.set_trace() instead of actually throwing an exception?

I

4条回答
  •  清歌不尽
    2021-02-04 04:13

    I wrote a package to start pdb on exception. It takes @boreis-gorelik's answer, and modifies the interpreter state at runtime so no code changes are necessary:

    Installation

     pip install mort
    

    Usage

    mort 
    

    When the exception occurs, the pdb repl should start in the given terminal

提交回复
热议问题