https://github.com/python/cpython/commit/251b5899ded42993373382ad571ca109f7b8132f
commit: 251b5899ded42993373382ad571ca109f7b8132f
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: hugovk <[email protected]>
date: 2026-08-06T15:54:14+03:00
summary:

[3.14] gh-155009: Fix argparse test on non-UTF-8 locales like Raspbian 
(GH-155227) (#155271)

Co-authored-by: Hugo van Kemenade <[email protected]>

files:
M Lib/test/test_argparse.py

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)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to