diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-09 10:21:14 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-09 10:21:14 (GMT) |
commit | bbbbe8eb600a9efa4c3a13ae49dcdcdbb051f22a (patch) | |
tree | d4095cce5f7f4152b120c29c7bc2e79d99942c1e /Lib/tempfile.py | |
parent | 4b109cb4a8dd2ad9d55913b682c6234f7bcd874e (diff) | |
download | cpython-bbbbe8eb600a9efa4c3a13ae49dcdcdbb051f22a.zip cpython-bbbbe8eb600a9efa4c3a13ae49dcdcdbb051f22a.tar.gz cpython-bbbbe8eb600a9efa4c3a13ae49dcdcdbb051f22a.tar.bz2 |
Issue #10355: SpooledTemporaryFile properties now work for unrolled files.
Remove obsoleted xreadline method.
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r-- | Lib/tempfile.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py index 86300b6..ae35314 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -546,7 +546,12 @@ class SpooledTemporaryFile: @property def encoding(self): - return self._file.encoding + try: + return self._file.encoding + except AttributeError: + if 'b' in self._TemporaryFileArgs['mode']: + raise + return self._TemporaryFileArgs['encoding'] def fileno(self): self.rollover() @@ -560,18 +565,26 @@ class SpooledTemporaryFile: @property def mode(self): - return self._file.mode + try: + return self._file.mode + except AttributeError: + return self._TemporaryFileArgs['mode'] @property def name(self): - return self._file.name + try: + return self._file.name + except AttributeError: + return None @property def newlines(self): - return self._file.newlines - - def next(self): - return self._file.next + try: + return self._file.newlines + except AttributeError: + if 'b' in self._TemporaryFileArgs['mode']: + raise + return self._TemporaryFileArgs['newline'] def read(self, *args): return self._file.read(*args) @@ -607,9 +620,6 @@ class SpooledTemporaryFile: self._check(file) return rv - def xreadlines(self, *args): - return self._file.xreadlines(*args) - class TemporaryDirectory(object): """Create and return a temporary directory. This has the same |