From: Terry Jan Reedy Date: Sun, 30 Jun 2013 17:57:57 +0000 (-0400) Subject: Tempfile.py: stop buildbot warning about using deprecated xreadlines. X-Git-Tag: v2.7.6rc1~321 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6c1d9dd566405a0da6b27b0847ab5fbe49b5b564;p=thirdparty%2FPython%2Fcpython.git Tempfile.py: stop buildbot warning about using deprecated xreadlines. 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). --- diff --git a/Lib/tempfile.py b/Lib/tempfile.py index f2ddbb0d9ca1..b5dce974e187 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -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))