Skip to content

Commit 10509c3

Browse files
hugovkmiss-islington
authored andcommitted
gh-155009: Fix argparse test on non-UTF-8 locales like Raspbian (GH-155227)
(cherry picked from commit 297eb1b) Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent 162bd7e commit 10509c3

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Lib/test/test_argparse.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7132,6 +7132,9 @@ def test_module_as_main_without_altering_argv(self):
71327132
basename = 'module' + os_helper.FS_NONASCII
71337133
modulename = f'{self.dirname}.{basename}'
71347134
self.make_script(self.dirname, basename)
7135+
# The filesystem encoding may be non-UTF-8,
7136+
# but the runner runs in UTF-8 mode
7137+
modulename = os.fsencode(modulename).decode("utf-8", "surrogateescape")
71357138
runner_source = textwrap.dedent(f'''\
71367139
import runpy
71377140
runpy._run_module_as_main({modulename!r}, alter_argv=False)

0 commit comments

Comments
 (0)