Guido van Rossum added the comment:

Note there's also a nasty corner case related to generators and GC. If a 
generator contains a with-block or finally-clause, and the generator is not run 
until its end because the caller hit an exception on one of the items returned, 
and the generator object is somehow kept alive (either because it's stored in 
some longer-living state or because the Python implementation doesn't use 
reference counting) then the close() call in the finally-clause or in the 
__exit__ method doesn't run until the generator object is garbage-collected.

IOW even making it a context manager doesn't completely solve this issue 
(though it can certainly help).

----------
nosy: +gvanrossum

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25994>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to