Message142515
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). |
|
Date |
User |
Action |
Args |
2011-08-20 06:37:56 | martin.panter | set | recipients:
+ martin.panter |
2011-08-20 06:37:56 | martin.panter | set | messageid: <1313822276.28.0.844478703688.issue12791@psf.upfronthosting.co.za> |
2011-08-20 06:37:55 | martin.panter | link | issue12791 messages |
2011-08-20 06:37:55 | martin.panter | create | |
|