[Python-checkins] cpython (2.7): Tempfile.py: stop buildbot warning about using deprecated xreadlines.
terry.reedy
python-checkins at python.org
Sun Jun 30 19:58:17 CEST 2013
http://hg.python.org/cpython/rev/1cdd9e680567
changeset: 84391:1cdd9e680567
branch: 2.7
parent: 84388:0e1d538d36dc
user: Terry Jan Reedy <tjreedy at udel.edu>
date: Sun Jun 30 13:57:57 2013 -0400
summary:
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).
files:
Lib/tempfile.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -612,7 +612,7 @@
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))
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list