Commit d83b7c2d authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #23700: NamedTemporaryFile iterator closed underlied file object in

some circunstances while NamedTemporaryFile object was living.  This causes
failing test_csv.  Changed the implementation of NamedTemporaryFile.__iter__
to make tests passed.
parent f0c6cd35
......@@ -426,9 +426,11 @@ class _TemporaryFileWrapper:
# iter() doesn't use __getattr__ to find the __iter__ method
def __iter__(self):
# don't return iter(self.file), but yield from it to avoid closing
# file as long as it's being used as iterator, see issue #23000
yield from iter(self.file)
# Don't return iter(self.file), but yield from it to avoid closing
# file as long as it's being used as iterator, see issue #23000.
# XXX Also don't use "yield from"!
for line in self.file:
yield line
def NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment