From 10509c34d6ebcd50505d53e64b23c6d6c4df8a38 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Thu, 6 Aug 2026 13:48:58 +0300 Subject: [PATCH] gh-155009: Fix argparse test on non-UTF-8 locales like Raspbian (GH-155227) (cherry picked from commit 297eb1b7488a46c8b6c4d87caaf658463ca72059) Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- Lib/test/test_argparse.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index e376c44faa4ae9..740119a952f81b 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -7132,6 +7132,9 @@ def test_module_as_main_without_altering_argv(self): 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)