From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Fri, 26 Feb 2021 02:36:27 +0000 (-0800) Subject: bpo-43316: gzip: Fix sys.exit() usage. (GH-24652) X-Git-Tag: v3.9.3~73 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=540749ed6d8e29a11368bc7f343baf7b7ea7e4a8;p=thirdparty%2FPython%2Fcpython.git bpo-43316: gzip: Fix sys.exit() usage. (GH-24652) (cherry picked from commit 9525a18b5bb317d9fb206c992ab62aa41559b0c8) Co-authored-by: Inada Naoki --- diff --git a/Lib/gzip.py b/Lib/gzip.py index 8002b43bde97..ee0cbed8f50d 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -583,7 +583,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: diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 66ae51acbff5..1af23c69b4bd 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -773,7 +773,7 @@ class TestCommandLine(unittest.TestCase): 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'')