mirror of
https://github.com/python/cpython.git
synced 2025-07-30 22:54:16 +00:00
Issue #2846: Add support for gzip.GzipFile reading zero-padded files.
Patch by Brian Curtin.
This commit is contained in:
parent
10042922d9
commit
5a9112c0cc
4 changed files with 27 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue