diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-20 16:11:20 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-20 16:11:20 +0200 |
commit | d83b7c2df4439b678bf7e372f8c9bbaff2907689 (patch) | |
tree | 1bdddaf5647aa414c92b67c5511854b04c63b434 /Lib/tempfile.py | |
parent | f0c6cd3581831cb5f10fe8244bffb9c5f2a754b2 (diff) | |
download | cpython-git-d83b7c2df4439b678bf7e372f8c9bbaff2907689.tar.gz |
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.
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r-- | Lib/tempfile.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py index 8352c38a0d..cb18ae65f6 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -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, |