Issue #1159051: Back out a fix for handling corrupted gzip files that

broke backwards compatibility.
This commit is contained in:
Georg Brandl 2013-05-12 11:29:27 +02:00
parent a9217a42e6
commit 93b061bc3e
4 changed files with 41 additions and 68 deletions

13
Lib/test/test_gzip.py Normal file → Executable file
View file

@ -365,19 +365,6 @@ class TestGzip(unittest.TestCase):
datac = gzip.compress(data)
self.assertEqual(gzip.decompress(datac), data)
def test_read_truncated(self):
data = data1*50
# Drop the CRC (4 bytes) and file size (4 bytes).
truncated = gzip.compress(data)[:-8]
with gzip.GzipFile(fileobj=io.BytesIO(truncated)) as f:
self.assertRaises(EOFError, f.read)
with gzip.GzipFile(fileobj=io.BytesIO(truncated)) as f:
self.assertEqual(f.read(len(data)), data)
self.assertRaises(EOFError, f.read, 1)
# Incomplete 10-byte header.
for i in range(2, 10):
with gzip.GzipFile(fileobj=io.BytesIO(truncated[:i])) as f:
self.assertRaises(EOFError, f.read, 1)
def test_read_with_extra(self):
# Gzip data with an extra field