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).
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))