Get last exception in pdb

前端 未结 5 1671
执笔经年
执笔经年 2020-12-16 11:41

Is there a way to examine the last exception when in pdb/before entering pdb? (Using python 2.7.5).

Immediately (yes, I enter no other commands at all) afte

5条回答
  •  粉色の甜心
    2020-12-16 12:07

    I bumped into this post, but none of the answers did what I needed, which was to repeat all of the error information (including the traceback) that was spewed before the pdb.pm() step in the question. Here's what worked for me in the end:

    Add the following lines to your .pdbrc file:

    import sys
    import traceback
    alias rethrow traceback.print_exception(sys.last_type, sys.last_value, sys.last_traceback)
    

    Now, next time you're in a pdb environment, you can just type rethrow, and it will repeat all the error information from before you had typed pdb.pm().

提交回复
热议问题