You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Handle corrupted gzip files with unexpected EOF #41668
I think the new behavior should be controlled by a constructor flag, maybe
named "defer_errors". I don't like the idea of adding the flag to read(),
since that makes us diverge from the standard file interface. Making a
distinction between size<0 and size=None seems confusing and error-prone,
not to mention that we (again) would have read() work differently from most
other file classes.
I'd prefer it if the new behavior is not enabled by default for size>=0,
even if this wouldn't break well-behaved code. Having a flag that only
controls the size<0 case is inelegant, and I don't think we should change
the default behavior unless there is a clear benefit to doing so.
tuned_gzip does dangerous things, it overloads private methods of GzipFile.
From Bazaar 2.3 Release Notes:
Stop using bzrlib.tuned_gzip.GzipFile. It is incompatible with
python-2.7 and was only used for Knit format repositories, which haven't
been recommended since 2007. The file itself will be removed in the next
release. (John Arbash Meinel)
Current version is 2.6b2. bzrlib.tuned_gzip.GzipFile should be removed two releases ago.
Traceback (most recent call last):
File "./feedparsertest.py", line 433, in test_gzip_struct_error
f = feedparser.parse('http://localhost:8097/tests/compression/gzip-struct-error.gz')
File "/build/buildd/feedparser-5.1.2/feedparser/feedparser.py", line 3836, in parse
data = gzip.GzipFile(fileobj=_StringIO(data)).read()
File "/usr/lib/python2.7/gzip.py", line 253, in readwhileself._read(readsize):
File "/usr/lib/python2.7/gzip.py", line 323, in _readself._read_eof()
File "/usr/lib/python2.7/gzip.py", line 340, in _read_eof
crc32, isize = struct.unpack("<II", self._read_exact(8))
File "/usr/lib/python2.7/gzip.py", line 189, in _read_exactraiseEOFError("Compressed file ended before the "EOFError: Compressed file ended before the end-of-stream marker was reached
Ran 4237 tests in 5.190s
FAILED (errors=1)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 43939)
In both cases broken applications use the undocumented implementation details. But such changes are extremely strong for bugfix release and they should not be done without a special need. I propose to revert these changes in 2.7, 3.2 and 3.3 (possibly leaving in the default branch). Unfortunately, I was not online right before the release of the latest bugfix release and failed to do this. Fortunately, it is now possible to fix this in regression fix releases.
Activity
nadeemvawda commentedon Feb 3, 2013
I think the new behavior should be controlled by a constructor flag, maybe
named "defer_errors". I don't like the idea of adding the flag to read(),
since that makes us diverge from the standard file interface. Making a
distinction between size<0 and size=None seems confusing and error-prone,
not to mention that we (again) would have read() work differently from most
other file classes.
I'd prefer it if the new behavior is not enabled by default for size>=0,
even if this wouldn't break well-behaved code. Having a flag that only
controls the size<0 case is inelegant, and I don't think we should change
the default behavior unless there is a clear benefit to doing so.
doko42 commentedon Mar 15, 2013
this change breaks a test case in the bzr testsuite; will try to get to it next week. See https://launchpad.net/bugs/1116079
serhiy-storchaka commentedon Mar 16, 2013
tuned_gzip does dangerous things, it overloads private methods of GzipFile.
From Bazaar 2.3 Release Notes:
bzrlib.tuned_gzip.GzipFile. It is incompatible withpython-2.7 and was only used for Knit format repositories, which haven't
been recommended since 2007. The file itself will be removed in the next
release. (John Arbash Meinel)
Current version is 2.6b2. bzrlib.tuned_gzip.GzipFile should be removed two releases ago.
serhiy-storchaka commentedon Mar 19, 2013
I will be offline some time. Feel free to revert these changes in 2.7-3.3 if it
is necessary.
doko42 commentedon Mar 30, 2013
another test case failure with this patch:
https://launchpad.net/ubuntu/+archive/test-rebuild-20130329/+build/4416983
reproducible with feedparser 5.1.3 from pypi, on x86 (but not x86_64).
ERROR: test_gzip_struct_error (main.TestCompression)
----------------------------------------------------------------------
Ran 4237 tests in 5.190s
FAILED (errors=1)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 43939)
serhiy-storchaka commentedon May 3, 2013
In both cases broken applications use the undocumented implementation details. But such changes are extremely strong for bugfix release and they should not be done without a special need. I propose to revert these changes in 2.7, 3.2 and 3.3 (possibly leaving in the default branch). Unfortunately, I was not online right before the release of the latest bugfix release and failed to do this. Fortunately, it is now possible to fix this in regression fix releases.
python-dev commentedon May 11, 2013
New changeset abc780332b60 by Benjamin Peterson in branch '2.7':
backout 214d8909513d for regressions (bpo-1159051)
http://hg.python.org/cpython/rev/abc780332b60
python-dev commentedon May 12, 2013
New changeset 854ba6f414a8 by Georg Brandl in branch '3.2':
Issue bpo-1159051: Back out a fix for handling corrupted gzip files that
http://hg.python.org/cpython/rev/854ba6f414a8
python-dev commentedon May 12, 2013
New changeset 9c2831fe84e9 by Georg Brandl in branch '3.3':
Back out patch for bpo-1159051, which caused backwards compatibility problems.
http://hg.python.org/cpython/rev/9c2831fe84e9
New changeset 5400e8fbc1de by Georg Brandl in branch 'default':
null-merge reversion of bpo-1159051 patch from 3.3
http://hg.python.org/cpython/rev/5400e8fbc1de
pythongh-41668: Retrigger CI for macOS runner
pythongh-41668: Retrigger CI