diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-09 10:21:52 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-09 10:21:52 (GMT) |
commit | 33182807f8daefdf4455c3190586f5a2c299820b (patch) | |
tree | 9608510297776818ae850fccfd1d4426f3cd5cd6 /Lib/tempfile.py | |
parent | 19a5214da47623fa3b8a8e321efe04584e2563c7 (diff) | |
parent | bbbbe8eb600a9efa4c3a13ae49dcdcdbb051f22a (diff) | |
download | cpython-33182807f8daefdf4455c3190586f5a2c299820b.zip cpython-33182807f8daefdf4455c3190586f5a2c299820b.tar.gz cpython-33182807f8daefdf4455c3190586f5a2c299820b.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 acd717b..61b0df1 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -537,7 +537,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() @@ -551,18 +556,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) @@ -603,9 +616,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 |