diff options
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 26f435456b..13f2ca24b7 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -330,6 +330,15 @@ class GzipFile(io.BufferedIOBase): elif isize != (self.size & 0xffffffffL): 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 = "\x00" + while c == "\x00": + c = self.fileobj.read(1) + if c: + self.fileobj.seek(-1, 1) + @property def closed(self): return self.fileobj is None |