[issue23700] tempfile.NamedTemporaryFile can close too early if used as iterator

Serhiy Storchaka report at bugs.python.org
Fri Mar 20 15:13:16 CET 2015


Serhiy Storchaka added the comment:

> csv.reader(fileobj) returns the generator created by fileobj.__iter__, but no reference to it is kept so the object gets destroyed right afterwards. This closes the generator and because it uses yield from also the contained subgenerator, which is the file itself.

Yes, there are no references to to the generator, created by fileobj.__iter__, but there are references to fileobj itself and to the file fileobj.file. I still don't understand why the file is closed. This looks as a bug.

Committed existing fix only to make buildbots green.

----------

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


More information about the Python-bugs-list mailing list