]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43316: gzip: Fix sys.exit() usage. (GH-24652)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 26 Feb 2021 02:36:27 +0000 (18:36 -0800)
committerGitHub <noreply@github.com>
Fri, 26 Feb 2021 02:36:27 +0000 (18:36 -0800)
(cherry picked from commit 9525a18b5bb317d9fb206c992ab62aa41559b0c8)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
Lib/gzip.py
Lib/test/test_gzip.py

index 8002b43bde97cda3d45f681fcc1143bb341b5335..ee0cbed8f50d6d827099ce8d333403f6cbea8645 100644 (file)
@@ -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:
index 66ae51acbff54b4d9f1a39ab1404b1e6286f04f9..1af23c69b4bd7b3dd917e27536083ae5265e7815 100644 (file)
@@ -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'')