Skip to content

Commit ec723e6

Browse files
committed
Fix BadGzipFile error
1 parent 36ac747 commit ec723e6

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

src/isal/igzip.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@
4141
BUFFER_SIZE = _compression.BUFFER_SIZE
4242

4343
try:
44-
class BadGzipFile(gzip.BadGzipFile):
45-
pass
44+
BadGzipFile = gzip.BadGzipFile
4645
except AttributeError: # Versions lower than 3.8 do not have BadGzipFile
47-
pass
46+
BadGzipFile = OSError
4847

4948

5049
# The open method was copied from the CPython source with minor adjustments.

tests/test_gzip_compliance.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -452,24 +452,15 @@ def test_zero_padded_file(self):
452452
d = f.read()
453453
self.assertEqual(d, data1 * 50, "Incorrect data in file")
454454

455-
@unittest.skipIf(sys.version_info[0] == 3 and sys.version_info[1] < 8
456-
or sys.version_info[0] < 3,
457-
reason="BadGzipFile exception only in version 3.8 or "
458-
"higher")
459455
def test_igzip_BadGzipFile_exception(self):
460456
self.assertTrue(issubclass(igzip.BadGzipFile, OSError))
461457

462458
def test_bad_gzip_file(self):
463459
major, minor, _, _, _ = sys.version_info
464-
if major == 3 and minor >= 8 or major > 3:
465-
error = gzip.BadGzipFile
466-
else:
467-
error = OSError
468-
469460
with open(self.filename, 'wb') as file:
470461
file.write(data1 * 50)
471462
with igzip.IGzipFile(self.filename, 'r') as file:
472-
self.assertRaises(error, file.readlines)
463+
self.assertRaises(igzip.BadGzipFile, file.readlines)
473464

474465
def test_non_seekable_file(self):
475466
uncompressed = data1 * 50

0 commit comments

Comments
 (0)