Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Lib/test/test_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -7350,6 +7350,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")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it run in UTF-8 mode? Should this be locale.getpreferredencoding(), to handle PYTHONUTF8=0 ?

But it's in test-only code, so this shouldn't block the release.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Hugo’s fix is sufficient here. check_usage() explicitly launches the child with -Xutf8, and -X utf8 takes precedence over PYTHONUTF8=0.

runner_source = textwrap.dedent(f'''\
import runpy
runpy._run_module_as_main({modulename!r}, alter_argv=False)
Expand Down
Loading