Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-90548: Allow Alpine/MUSL to pass test_c_locale_coercion.#134454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
bitdancer wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
frombitdancer:alpine_test_c_locale_coercion_fix

Conversation

bitdancer
Copy link
Member

@bitdancerbitdancer commentedMay 21, 2025
edited by bedevere-appbot
Loading

Like cygwin, MUSL defaults to utf-8 if no variables are set. I have no idea if the existing tests pass on cygwin, but I made the modifications such that I shouldn't break it if is. The additional checks needed for MUSL are guarded by DEFAULT_LOCALE_IS_C being False. Based on this flag, we expect utf-8 for the encodings and no coercion message, as long as LC_ALL is not set to C. (That looks like a bit of an issue with the test structure, but I'm not going to attempt to "fix" that.) DEFAULT_ENCODING is intentionally not given a default since it is only used when DEFAULT_LOCALE_IS_C is False, and if you use the flag you'll need to set it.

After reading through issue 30672, looking at the source, and running a test on Android, Ithink the current situation is that coercion will be done if the local is set to POSIX regardless of platform. However, if the platform doesn't make POSIX equivalent to C, the encodings when coercion is disabled will not be the same as for C (it is utf-8 on android, for example). This means the tests would fail if POSIX were added unconditionally to the EXPECTED_C_LOCALE_EQUIVALENTS as envisioned in the issue. Thiscould be fixed with another flag, but I'm not sure it is worth the effort. I'm not even sure Python is behaving optimally in this case (assuming my analysis is correct). So I just altered the comment and add POSIX if and only if the platform is linux.

Like cygwin, MUSL defaults to utf-8 if no variables are set.  I have noidea if the existing tests pass on cygwin, but I made the modificationssuch that I shouldn't break it if is.  The additional checks needed forMUSL are guarded by DEFAULT_LOCALE_IS_C being False.  Based on thisflag, we expect utf-8 for the encodings and no coercion message, aslong as LC_ALL is not set to C.  (That looks like a bit of an issue withthe test structure, but I'm not going to attempt to "fix" that.)DEFAULT_ENCODING is intentionally not given a default since it is onlyused when DEFAULT_LOCALE_IS_C is False, and if you use the flag you'llneed to set it.After reading through issue 30672, looking at the source, and running atest on Android, I *think* the current situation is that coercion willbe done if the local is set to POSIX regardless of platform.  However,if the platform doesn't make POSIX equivalent to C, the encodings whencoercion is disabled will not be the same as for C (it is utf-8 onandroid, for example).  This means the tests would fail if POSIX wereadded unconditionally to the EXPECTED_C_LOCALE_EQUIVALENTS as envisionedin the issue.  This *could* be fixed with another flag, but I'm not sureit is worth the effort.  I'm not even sure Python is behaving optimallyin this case (assuming my analysis is correct).  So I just altered thecomment and add POSIX if and only if the platform is linux.
@vstinner
Copy link
Member

cc@ncoghlan

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

@ncoghlanncoghlanAwaiting requested review from ncoghlan

Assignees
No one assigned
Labels
awaiting core reviewskip newstestsTests in the Lib/test dir
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@bitdancer@vstinner

[8]ページ先頭

©2009-2025 Movatter.jp