You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
traceback.print_last() depends on the existence of sys.last_type,
sys.last_value, sys.last_traceback, which don't always exist when
called. See attached example file. I will shortly send the patch for Lib/traceback.py
I haven't submitted a patch since the transition from sf.net to
bugs.python.org; I assume that I don't have to open a new patch for
this, but if I have to, please let me know and I will gladly do it.
The unified diff is attached; the test example I issued works with the
patched version.
traceback.print_last() depends on the existence of sys.last_type
Yes, that is exactly as documented:
>>> help(traceback.print_last)
Help on function print_last in module traceback:
print_last(limit=None, file=None)
This is a shorthand for 'print_exception(sys.last_type,
sys.last_value, sys.last_traceback, limit, file)'.
Furthermore, in the doc: http://docs.python.org/dev/library/sys.html#sys.last_type
"... they are set when an exception is not handled ..."
In your script, you *are* handling the exception.
Your script really should use traceback.print_exc() instead.
BTW, your patch basically makes print_last() identical to print_exc()...
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: