Skip to content

Commit 77e1922

Browse files
authored
Merge pull request #46 from pycompression/updatecli
Update CLI to reflect https://bugs.python.org/issue43316
2 parents 146c7f8 + 7bdb235 commit 77e1922

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ Changelog
99
1010
version 0.6.0-dev
1111
-----------------
12+
+ ``python -m gzip``'s behaviour has been changed since fixing bug:
13+
`bpo-43316 <https://bugs.python.org/issue43316>`_. This bug was not present
14+
in ``python -m isal.igzip`` but it handled the error differently than the
15+
solution in CPython. This is now corrected and ``python -m isal.igzip``
16+
handles the error the same as the fixed ``python -m gzip``.
1217
+ Installation on Windows is now supported. Wheels are provided for Windows as
1318
well.
1419

src/isal/igzip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def main():
295295
elif not args.compress and args.file is not None:
296296
base, extension = os.path.splitext(args.file)
297297
if extension != ".gz":
298-
raise ValueError(f"filename doesn't end in .gz: {args.file}. ")
298+
sys.exit(f"filename doesn't end in .gz: {args.file!r}")
299299
in_file = open(args.file, "rb")
300300

301301
# Determine output file

tests/test_gzip_compliance.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -823,14 +823,9 @@ def test_decompress_infile_outfile(self):
823823
def test_decompress_infile_outfile_error(self):
824824
rc, out, err = assert_python_failure('-m', 'isal.igzip', '-d',
825825
'thisisatest.out')
826-
# We take a divide from the original gzip module here. Error messages
827-
# should be printed in stderr. Also exit code should not be 0!
828-
# in python -m gzip -d mycompressedfile > decompressed
829-
# will simply make decompressed contents 'filename doesn't end in .gz'
830-
# without throwing an error. Crazy!
831-
# TODO: Report a bug in CPython for gzip module
832-
self.assertIn(b"filename doesn't end in .gz:", err)
833-
self.assertNotEqual(rc, 0)
826+
self.assertEqual(b"filename doesn't end in .gz: 'thisisatest.out'",
827+
err.strip())
828+
self.assertEqual(rc, 1)
834829
self.assertEqual(out, b'')
835830

836831
@create_and_remove_directory(TEMPDIR)

tests/test_igzip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def test_compress_infile_outfile(tmp_path, capsysbinary):
9292

9393
def test_decompress_infile_outfile_error(capsysbinary):
9494
sys.argv = ['', '-d', 'thisisatest.out']
95-
with pytest.raises(ValueError) as error:
95+
with pytest.raises(SystemExit) as error:
9696
igzip.main()
9797
assert error.match("filename doesn't end")
9898
out, err = capsysbinary.readouterr()

0 commit comments

Comments
 (0)