[docs] [issue17468] Generator memory leak

Nick Coghlan report at bugs.python.org
Sat Apr 20 16:55:34 CEST 2013


Nick Coghlan added the comment:

We can't make ordinary generators innately context managers, as it makes the error too hard to detect when you accidentally leave out @contextmanager when using a generator to write a custom one.

You can already use contextlib.closing to forcibly close them when appropriate, so providing a decorator to implicitly map __exit__ to close wouldn't really save much.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17468>
_______________________________________


More information about the docs mailing list