[issue28629] Emit ResourceWarning when implicitly terminating a suspended frame?

Martin Panter report at bugs.python.org
Mon Nov 14 02:59:46 EST 2016


Martin Panter added the comment:

BTW my understanding is that currently, if the garbage collector deletes a generator, it effectively calls its close() method. When close() is called, it throws GeneratorExit into the suspended generator. This is meant to cause all the “with” and “try” statements to clean up.

So, yes, explicitly calling close() should immediately release the resources, call obj.__exit__(), etc. The idea of the ResourceWarning is to tell the programmer they forgot to call close().

----------

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


More information about the Python-bugs-list mailing list