This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients martin.panter
Date 2011-08-20.06:37:55
SpamBayes Score 2.7928715e-11
Marked as misclassified No
Message-id <1313822276.28.0.844478703688.issue12791@psf.upfronthosting.co.za>
In-reply-to
Content
See attached "leaky_generator.py" demo. Python doesn't appear to delete the exception variable if an exception is thrown back into it (via "throw", "close" or by deleting it). The result is a reference cycle that needs garbage collecting. This even happens when no exception variable is named. The exception variable is not leaked if the generator is called normally (via "next" or "send").

The exception variable of an exception handler is usually deleted (according to http://docs.python.org/py3k/reference/compound_stmts.html#the-try-statement) as soon as the handler is exited, even when it is not exited by simply falling through the end. So either this should also happen for "yield" inside the exception handler, or it should be documented that "yield" inside "except", even without "as", should be avoided.

I'm guessing this issue is specific to Python 3 because it exists for me in Python 3.2, 3.2.1 (both on Arch Linux) and 3.1.2 (Ubuntu) but not Python 2.7.1, 2.7.2 (Arch) nor 2.6.5 (Ubuntu).
History
Date User Action Args
2011-08-20 06:37:56martin.pantersetrecipients: + martin.panter
2011-08-20 06:37:56martin.pantersetmessageid: <1313822276.28.0.844478703688.issue12791@psf.upfronthosting.co.za>
2011-08-20 06:37:55martin.panterlinkissue12791 messages
2011-08-20 06:37:55martin.pantercreate