We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a4d4dd3 + 75ed90a commit 5d06c74Copy full SHA for 5d06c74
1 file changed
Lib/tempfile.py
@@ -427,8 +427,10 @@ def close(self):
427
# iter() doesn't use __getattr__ to find the __iter__ method
428
def __iter__(self):
429
# Don't return iter(self.file), but yield from it to avoid closing
430
- # file as long as it's being used as iterator, see issue #23000.
431
- # XXX Also don't use "yield from"!
+ # file as long as it's being used as iterator (see issue #23700). We
+ # can't use 'yield from' here because iter(file) returns the file
432
+ # object itself, which has a close method, and thus the file would get
433
+ # closed when the generator is finalized, due to PEP380 semantics.
434
for line in self.file:
435
yield line
436
0 commit comments