Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bpo-43316: gzip: Fix sys.exit() usage. (GH-24652)
(cherry picked from commit 9525a18)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
  • Loading branch information
methane authored and miss-islington committed Feb 26, 2021
commit 51a5c2efda646a5ed5fed90e4f7261a42817df54
2 changes: 1 addition & 1 deletion Lib/gzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def main():
g = sys.stdout.buffer
else:
if arg[-3:] != ".gz":
sys.exit("filename doesn't end in .gz:", repr(arg))
sys.exit(f"filename doesn't end in .gz: {arg!r}")
f = open(arg, "rb")
g = builtins.open(arg[:-3], "wb")
else:
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_gzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ def test_decompress_infile_outfile(self):

def test_decompress_infile_outfile_error(self):
rc, out, err = assert_python_failure('-m', 'gzip', '-d', 'thisisatest.out')
self.assertIn(b"filename doesn't end in .gz:", err)
self.assertEqual(b"filename doesn't end in .gz: 'thisisatest.out'", err.strip())
self.assertEqual(rc, 1)
self.assertEqual(out, b'')

Expand Down