summaryrefslogtreecommitdiffstats
path: root/Lib/gzip.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/gzip.py')
-rw-r--r--Lib/gzip.py9
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