Greg Hazel <[email protected]> added the comment:
The objects I do want in the traceback are the objects necessary to print a
traceback, but not the locals and globals of each frame.
For example:
def bar():
x = "stuff"
raise Exception("example!")
bar()
prints:
Traceback (most recent call last):
Line 4, in <module>
bar()
Line 3, in bar
raise Exception("example!")
Exception: example!
There is no reason in that example to have a reference to "x" in the traceback,
since it's not used in the output. This becomes important when I try to save a
reference to the traceback object and raise it later:
import sys
def bar():
x = "stuff"
raise Exception("example!")
try:
bar()
except:
exc_info = sys.exc_info()
def foo(e):
raise e[0], e[1], e[2]
# sometime possibly much later...
foo(exc_info)
Traceback (most recent call last):
Line 12, in <module>
foo(exc_info)
Line 6, in <module>
bar()
Line 4, in bar
raise Exception("example!")
Exception: example!
During that "sometime possibly much later..." comment, a reference to "x" is
held, when it will not be used in printing the traceback later. So, I would not
like to keep a reference to "x", and currently there is no way to do that
without also dropping a reference to the data needed to print the traceback.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue1565525>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com