python - Get last exception in pdb -


is there way examine last exception when in pdb/before entering pdb? (using python 2.7.5).

immediately (yes, enter no other commands @ all) after exception being raised in code, sys.exc_info(); results in (none, none, none). @ point, can pdb.pm(), , pdb starts @ point exception raised.

i'd able examine exception object (it not stored in variable before being raised).

there nothing helpful in http://docs.python.org/2/library/pdb.html or http://docs.python.org/2/library/sys.html

edit: know set_trace. i'd examine exception before modify code.

you can use sys.last_value:

>>> no_such_var traceback (most recent call last):   file "<stdin>", line 1, in <module> nameerror: name 'no_such_var' not defined >>> import sys >>> sys.last_value nameerror("name 'no_such_var' not defined",) >>> sys.last_value.args ("name 'no_such_var' not defined",) 

>>> no_such_var traceback (most recent call last):   file "<stdin>", line 1, in <module> nameerror: name 'no_such_var' not defined >>> import pdb, sys >>> pdb.set_trace() --return-- > <stdin>(1)<module>()->none (pdb) sys.last_value nameerror("name 'no_such_var' not defined",) 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -