]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Tempfile.py: stop buildbot warning about using deprecated xreadlines.
authorTerry Jan Reedy <tjreedy@udel.edu>
Sun, 30 Jun 2013 17:57:57 +0000 (13:57 -0400)
committerTerry Jan Reedy <tjreedy@udel.edu>
Sun, 30 Jun 2013 17:57:57 +0000 (13:57 -0400)
The slightly odd behavior (the validity of passing a sizehint depends on the
type of self._file) was kept to avoid breaking code that depends on it.
Test_tempfile.test_xreadlines passes (along with everything else).

Lib/tempfile.py

index f2ddbb0d9ca1a12797cd322103ed18d5c0ead294..b5dce974e18776fe4936d287221d5aff0f0f8cdf 100644 (file)
@@ -612,7 +612,7 @@ class SpooledTemporaryFile:
         return rv
 
     def xreadlines(self, *args):
-        try:
-            return self._file.xreadlines(*args)
-        except AttributeError:
+        if hasattr(self._file, 'xreadlines'):  # real file
+            return iter(self._file)
+        else:  # StringIO()
             return iter(self._file.readlines(*args))