]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-155009: Fix argparse test on non-UTF-8 locales like Raspbian (#155227)
authorHugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Thu, 6 Aug 2026 10:48:58 +0000 (13:48 +0300)
committerGitHub <noreply@github.com>
Thu, 6 Aug 2026 10:48:58 +0000 (13:48 +0300)
Lib/test/test_argparse.py

index 950671e4395cd4da59023b83e50eb707ba324dbe..1193cdca3e4e1953bd4a9a08df1bcdaf76df0eb8 100644 (file)
@@ -7364,6 +7364,9 @@ class TestProgName(TestCase):
         basename = 'module' + os_helper.FS_NONASCII
         modulename = f'{self.dirname}.{basename}'
         self.make_script(self.dirname, basename)
+        # The filesystem encoding may be non-UTF-8,
+        # but the runner runs in UTF-8 mode
+        modulename = os.fsencode(modulename).decode("utf-8", "surrogateescape")
         runner_source = textwrap.dedent(f'''\
             import runpy
             runpy._run_module_as_main({modulename!r}, alter_argv=False)