Xavier de Gaye <xdeg...@gmail.com> added the comment:
This is not a bug. On the first pdb session from the OP: True --Return-- > <ipython-input-2-9d1238ac9b7a>(5)<module>()->None -> import pdb; pdb.set_trace() (Pdb) print("err" in locals()) False <-------------- BUG?? Pdb has stopped on a '--Return--' line event, so we are already outside the scope of the except clause and the 'err' local variable cannot be accessed outside the except block. The following code snippet shows that pdb stops at the line following the set_trace() call: ================== def foo(): try: 1/0 except Exception as err: import pdb; pdb.set_trace() x= 1 foo() ================== And the corresponding pdb session: $ python foo.py > /path/to/foo.py(6)foo() -> x= 1 (Pdb) err *** NameError: name 'err' is not defined (Pdb) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36537> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com