sys.last_traceback - annoying pdb behaviour

Hi there, when I tried to use pdb, I spotted some kind of annoying behaviour of pdb: for pdb.pm, it still uses sys.last_traceback which is set by code.py This renders the function unusable in non-interactive contexts ... I suggest to change pdb.pm to use sys.exc_traceback instead. Any reasons not to do so? For Py3k, it might make sense to kill it completly. Besides that, some other places in the stdlib reference this attr as well: idle in 5 places ./lib-tk/Tkinter.py: sys.last_traceback = tb ./traceback.py: sys.last_value, sys.last_traceback, limit, file)'.""" ./traceback.py: print_exception(sys.last_type, sys.last_value, sys.last_traceback, ./pdb.py: post_mortem(sys.last_traceback) ./code.py: type, value, sys.last_traceback = sys.exc_info() ./code.py: sys.last_traceback = tb ./dis.py: tb = sys.last_traceback Kind regards, Alexander

sys.last_traceback is the only place where you can reliably find the latest *uncaught* traceback. There is no intention to get rid of it in Py3k or to change this behavior. If you have another traceback you'd like to print, you can use pdb.post_mortem(sys.exc_info()[2]). On 8/18/07, Alexander Schremmer <2006a@usenet.alexanderweb.de> wrote:
-- --Guido van Rossum (home page: http://www.python.org/~guido/)

On 8/18/07, Alexander Schremmer <2007a@usenet.alexanderweb.de> wrote:
Indeed, I did not see that it is also set in pythonrun. How do you think about changing pdb.pm to use exc_info if last_exception is not set?
That would just confuse you if you're counting on that behavior, and then some time later last_exception gets set and you suddenly don't get the behavior you expected. pdb.pm() is *only* for use at the command-line prompt (that's why its name is so short :-). -- --Guido van Rossum (home page: http://www.python.org/~guido/)

sys.last_traceback is the only place where you can reliably find the latest *uncaught* traceback. There is no intention to get rid of it in Py3k or to change this behavior. If you have another traceback you'd like to print, you can use pdb.post_mortem(sys.exc_info()[2]). On 8/18/07, Alexander Schremmer <2006a@usenet.alexanderweb.de> wrote:
-- --Guido van Rossum (home page: http://www.python.org/~guido/)

On 8/18/07, Alexander Schremmer <2007a@usenet.alexanderweb.de> wrote:
Indeed, I did not see that it is also set in pythonrun. How do you think about changing pdb.pm to use exc_info if last_exception is not set?
That would just confuse you if you're counting on that behavior, and then some time later last_exception gets set and you suddenly don't get the behavior you expected. pdb.pm() is *only* for use at the command-line prompt (that's why its name is so short :-). -- --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (3)
-
Alexander Schremmer
-
Alexander Schremmer
-
Guido van Rossum