Antoine Pitrou <[email protected]> added the comment:
The problem is probably that the frame keeps the last execution state around,
and since the exception itself has a reference to a frame, a cycle is created.
Note that it doesn't happen if you catch the GeneratorExit that gets raised
inside the generator at shutdown:
def leaky_generator():
try:
1/0
except: # Exception handler with anonymous exception variable
try:
yield # Yield from exception handler
except (GeneratorExit, RuntimeError):
pass
def throw_leaks(g):
try:
g.throw(RuntimeError())
except Exception:
pass
----------
nosy: +benjamin.peterson, ncoghlan
title: Yield" leaks exception being handled as garbage -> reference cycle with
exception state not broken by generator.close()
versions: +Python 3.3 -Python 3.1
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue12791>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com