[issue22166] test_codecs "leaking" references
STINNER Victor
report at bugs.python.org
Tue Sep 2 02:19:18 CEST 2014
STINNER Victor added the comment:
ExceptionChainingTest uses a function to raise an arbitrary exception. Problem: the function and its parameter becomes part of the exception traceback. Shortly, the exception links indirectly to itself in a nice reference cycle...
Example:
---
import traceback
class Err(Exception):
def __del__(self):
print("del")
def raise_exc(exc):
raise exc
e = Err()
try:
raise_exc(e)
except Exception as e:
t = e.__traceback__
#traceback.clear_frames(t)
e = None
print("exit")
---
Uncommand the call the clear_frames() to see the exception deleted before the exit.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22166>
_______________________________________
More information about the Python-bugs-list
mailing list