diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-13 14:37:26 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-13 14:37:26 (GMT) |
commit | 8e33fd78c4db7b250995652510067d7f3a8117cd (patch) | |
tree | 2aca383967f6dcca3ef0785ebe1ed6899a4821bf /Lib/gzip.py | |
parent | f068f94e82aaab9789c8b1065ec5f7fb94fa70ad (diff) | |
download | cpython-8e33fd78c4db7b250995652510067d7f3a8117cd.zip cpython-8e33fd78c4db7b250995652510067d7f3a8117cd.tar.gz cpython-8e33fd78c4db7b250995652510067d7f3a8117cd.tar.bz2 |
Merged revisions 77472-77473 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77472 | antoine.pitrou | 2010-01-13 15:32:10 +0100 (mer., 13 janv. 2010) | 5 lines
Issue #2846: Add support for gzip.GzipFile reading zero-padded files.
Patch by Brian Curtin.
........
r77473 | antoine.pitrou | 2010-01-13 15:32:51 +0100 (mer., 13 janv. 2010) | 3 lines
Add ACKS entry for r77472.
........
Diffstat (limited to 'Lib/gzip.py')
-rw-r--r-- | Lib/gzip.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py index 66fc88d..ef6befc 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -348,6 +348,15 @@ class GzipFile(io.BufferedIOBase): elif isize != (self.size & 0xffffffff): raise IOError("Incorrect length of data produced") + # Gzip files can be padded with zeroes and still have archives. + # Consume all zero bytes and set the file position to the first + # non-zero byte. See http://www.gzip.org/#faq8 + c = b"\x00" + while c == b"\x00": + c = self.fileobj.read(1) + if c: + self.fileobj.seek(-1, 1) + @property def closed(self): return self.fileobj is None |