cpython: ab6496b98ac4 (original) (raw)
Mercurial > cpython
changeset 76918:ab6496b98ac4
Issue #13815: Resurrect the ExFileObject class. After a discussion in the tracker, the decision was made to keep the ExFileObject class after all as a subclass of io.BufferedReader instead of removing it completely. [#13815]
Lars Gustäbel lars@gustaebel.de | |
---|---|
date | Mon, 14 May 2012 13🔞16 +0200 |
parents | 8a8120ee1202 |
children | 1338b6fece2d |
files | Lib/tarfile.py Misc/NEWS |
diffstat | 2 files changed, 11 insertions(+), 10 deletions(-)[+] [-] Lib/tarfile.py 17 Misc/NEWS 4 |
line wrap: on
line diff
--- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -758,6 +758,13 @@ class _FileInFile(object): self.closed = True #class _FileInFile +class ExFileObject(io.BufferedReader): +
- def init(self, tarfile, tarinfo):
fileobj = _FileInFile(tarfile.fileobj, tarinfo.offset_data,[](#l1.10)
tarinfo.size, tarinfo.sparse)[](#l1.11)
super().__init__(fileobj)[](#l1.12)
+#class ExFileObject #------------------
Exported Classes
@@ -1443,8 +1450,7 @@ class TarFile(object): tarinfo = TarInfo # The default TarInfo class to use.
def init(self, name=None, mode="r", fileobj=None, format=None, tarinfo=None, dereference=None, ignore_zeros=None, encoding=None, @@ -2081,12 +2087,7 @@ class TarFile(object): if tarinfo.isreg() or tarinfo.type not in SUPPORTED_TYPES: # Members with unknown types are treated as regular files.
if self.fileobject is None:[](#l1.31)
fileobj = _FileInFile(self.fileobj, tarinfo.offset_data, tarinfo.size, tarinfo.sparse)[](#l1.32)
return io.BufferedReader(fileobj)[](#l1.33)
else:[](#l1.34)
# Keep the traditional pre-3.3 API intact.[](#l1.35)
return self.fileobject(self, tarinfo)[](#l1.36)
return self.fileobject(self, tarinfo)[](#l1.37)
elif tarinfo.islnk() or tarinfo.issym(): if isinstance(self.fileobj, _Stream):
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -26,6 +26,8 @@ Core and Builtins Library ------- +- Issue #13815: TarFile.extractfile() now returns io.BufferedReader objects. +
- Issue #14532: Add a secure_compare() helper to the hmac module, to mitigate timing attacks. Patch by Jon Oberheide. @@ -181,8 +183,6 @@ Core and Builtins Library ------- -- Issue #13815: TarFile.extractfile() now returns io.BufferedReader objects. -
- Issue #14768: os.path.expanduser('~/a') doesn't works correctly when HOME is '/'.
- Issue #14371: Support bzip2 in zipfile module. Patch by Serhiy Storchaka.