]> granicus.if.org Git - python/commitdiff
#23700: fix/improve comment
authorR David Murray <rdmurray@bitdance.com>
Sun, 22 Mar 2015 16:33:46 +0000 (12:33 -0400)
committerR David Murray <rdmurray@bitdance.com>
Sun, 22 Mar 2015 16:33:46 +0000 (12:33 -0400)
Lib/tempfile.py

index cb18ae65f603033e0eaddd092f6b28d56dab3514..5eafc1fe7aaf46a10c59ed4b4bdb7625d9306e87 100644 (file)
@@ -427,8 +427,10 @@ 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.
-        # 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
+        # object itself, which has a close method, and thus the file would get
+        # closed when the generator is finalized, due to PEP380 semantics.
         for line in self.file:
             yield line