Back out patch for #1159051, which caused backwards compatibility pro… · python/cpython@b3bd624 · GitHub
Skip to content

Commit b3bd624

Browse files
committed
Back out patch for #1159051, which caused backwards compatibility problems.
1 parent 64949fa commit b3bd624

5 files changed

Lines changed: 44 additions & 82 deletions

File tree

Lib/gzip.py

Lines changed: 44 additions & 37 deletions

Lib/test/test_bz2.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -577,20 +577,6 @@ def testSeekBackwardsBytesIO(self):
577577
bz2f.seek(-150, 1)
578578
self.assertEqual(bz2f.read(), self.TEXT[500-150:])
579579

580-
def test_read_truncated(self):
581-
# Drop the eos_magic field (6 bytes) and CRC (4 bytes).
582-
truncated = self.DATA[:-10]
583-
with BZ2File(BytesIO(truncated)) as f:
584-
self.assertRaises(EOFError, f.read)
585-
with BZ2File(BytesIO(truncated)) as f:
586-
self.assertEqual(f.read(len(self.TEXT)), self.TEXT)
587-
self.assertRaises(EOFError, f.read, 1)
588-
# Incomplete 4-byte file header, and block header of at least 146 bits.
589-
for i in range(22):
590-
with BZ2File(BytesIO(truncated[:i])) as f:
591-
self.assertRaises(EOFError, f.read, 1)
592-
593-
594580
class BZ2CompressorTest(BaseTest):
595581
def testCompress(self):
596582
bz2c = BZ2Compressor()

Lib/test/test_gzip.py

100644100755
Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -389,20 +389,6 @@ def test_decompress(self):
389389
datac = gzip.compress(data)
390390
self.assertEqual(gzip.decompress(datac), data)
391391

392-
def test_read_truncated(self):
393-
data = data1*50
394-
# Drop the CRC (4 bytes) and file size (4 bytes).
395-
truncated = gzip.compress(data)[:-8]
396-
with gzip.GzipFile(fileobj=io.BytesIO(truncated)) as f:
397-
self.assertRaises(EOFError, f.read)
398-
with gzip.GzipFile(fileobj=io.BytesIO(truncated)) as f:
399-
self.assertEqual(f.read(len(data)), data)
400-
self.assertRaises(EOFError, f.read, 1)
401-
# Incomplete 10-byte header.
402-
for i in range(2, 10):
403-
with gzip.GzipFile(fileobj=io.BytesIO(truncated[:i])) as f:
404-
self.assertRaises(EOFError, f.read, 1)
405-
406392
def test_read_with_extra(self):
407393
# Gzip data with an extra field
408394
gzdata = (b'\x1f\x8b\x08\x04\xb2\x17cQ\x02\xff'

Lib/test/test_lzma.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -669,20 +669,6 @@ def test_read_incomplete(self):
669669
with LZMAFile(BytesIO(COMPRESSED_XZ[:128])) as f:
670670
self.assertRaises(EOFError, f.read)
671671

672-
def test_read_truncated(self):
673-
# Drop stream footer: CRC (4 bytes), index size (4 bytes),
674-
# flags (2 bytes) and magic number (2 bytes).
675-
truncated = COMPRESSED_XZ[:-12]
676-
with LZMAFile(BytesIO(truncated)) as f:
677-
self.assertRaises(EOFError, f.read)
678-
with LZMAFile(BytesIO(truncated)) as f:
679-
self.assertEqual(f.read(len(INPUT)), INPUT)
680-
self.assertRaises(EOFError, f.read, 1)
681-
# Incomplete 12-byte header.
682-
for i in range(12):
683-
with LZMAFile(BytesIO(truncated[:i])) as f:
684-
self.assertRaises(EOFError, f.read, 1)
685-
686672
def test_read_bad_args(self):
687673
f = LZMAFile(BytesIO(COMPRESSED_XZ))
688674
f.close()

Misc/NEWS

Lines changed: 0 additions & 3 deletions

0 commit comments

Comments
 (0)