From 07ab490a7a966ce00a61bf56ccd0604434b143a5 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Thu, 25 Feb 2021 18:36:49 -0800 Subject: [PATCH] bpo-43316: gzip: Fix sys.exit() usage. (GH-24652) (cherry picked from commit 9525a18b5bb317d9fb206c992ab62aa41559b0c8) Co-authored-by: Inada Naoki --- Lib/gzip.py | 2 +- Lib/test/test_gzip.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/gzip.py b/Lib/gzip.py index 3dd8564bec35..1101d35a5f1b 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -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: diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 4bbc7424eb8a..5c70a9e72635 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -761,7 +761,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'') -- 2.47.3