mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #23700: Iterator of NamedTemporaryFile now keeps a reference to
NamedTemporaryFile instance. Patch by Bohuslav Kabrda.
This commit is contained in:
parent
86fdbf3152
commit
56cefa69ee
3 changed files with 19 additions and 1 deletions
|
@ -426,7 +426,9 @@ class _TemporaryFileWrapper:
|
|||
|
||||
# iter() doesn't use __getattr__ to find the __iter__ method
|
||||
def __iter__(self):
|
||||
return 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
|
||||
yield from iter(self.file)
|
||||
|
||||
|
||||
def NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue