[Python-checkins] cpython (3.4): #23700: fix/improve comment

r.david.murray python-checkins at python.org
Sun Mar 22 17:35:05 CET 2015


https://hg.python.org/cpython/rev/e9f03315d66c
changeset:   95127:e9f03315d66c
branch:      3.4
parent:      95123:e5de4ee6aa4a
user:        R David Murray <rdmurray at bitdance.com>
date:        Sun Mar 22 12:33:46 2015 -0400
summary:
  #23700: fix/improve comment

files:
  Lib/tempfile.py |  6 ++++--
  1 files changed, 4 insertions(+), 2 deletions(-)


diff --git a/Lib/tempfile.py b/Lib/tempfile.py
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -427,8 +427,10 @@
     # 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
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list