diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-09 10:22:29 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-09 10:22:29 (GMT) |
commit | 5d70ccc4a9e7d6c4f56a53c922110f69368617e6 (patch) | |
tree | 4c1e20b46c45353eda17f1fe47a6ea9a1efb0107 /Lib/tempfile.py | |
parent | 9ea2d55d91c273cfbbdd7acc664070d9ecdcda14 (diff) | |
parent | 33182807f8daefdf4455c3190586f5a2c299820b (diff) | |
download | cpython-5d70ccc4a9e7d6c4f56a53c922110f69368617e6.zip cpython-5d70ccc4a9e7d6c4f56a53c922110f69368617e6.tar.gz cpython-5d70ccc4a9e7d6c4f56a53c922110f69368617e6.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 0785d80..8f8743c4 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -539,7 +539,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() @@ -553,18 +558,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) @@ -605,9 +618,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 |