Skip to content

gh-155009: Fix argparse test on non-UTF-8 locales like Raspbian - #155227

Open
hugovk wants to merge 1 commit into
python:mainfrom
hugovk:3.16-fix-raspbian
Open

gh-155009: Fix argparse test on non-UTF-8 locales like Raspbian#155227
hugovk wants to merge 1 commit into
python:mainfrom
hugovk:3.16-fix-raspbian

Conversation

@hugovk

@hugovk hugovk commented Aug 5, 2026

Copy link
Copy Markdown
Member

@bedevere-app bedevere-app Bot added tests Tests in the Lib/test dir awaiting core review labels Aug 5, 2026
@hugovk hugovk added needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes and removed tests Tests in the Lib/test dir awaiting core review labels Aug 5, 2026
@hugovk hugovk changed the title Fix argparse test on non-UTF-8 locales like Raspbian gh-155009: Fix argparse test on non-UTF-8 locales like Raspbian Aug 5, 2026
@hugovk

hugovk commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

!buildbot ARM64 Raspbian

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @hugovk for commit be68e22 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F155227%2Fmerge

The command will test the builders whose names match following regular expression: ARM64 Raspbian

The builders matched are:

  • ARM64 Raspbian PR
  • ARM64 Raspbian Debug PR

Comment thread Lib/test/test_argparse.py
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.

@savannahostrowski savannahostrowski left a comment

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.

Thanks for this, Hugo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants