gh-137729: Fix support for locales with @-modifiers by serhiy-storchaka · Pull Request #137253 · python/cpython · GitHub
Skip to content

gh-137729: Fix support for locales with @-modifiers#137253

Merged
serhiy-storchaka merged 8 commits into
python:mainfrom
serhiy-storchaka:locale-modifiers
Aug 18, 2025
Merged

gh-137729: Fix support for locales with @-modifiers#137253
serhiy-storchaka merged 8 commits into
python:mainfrom
serhiy-storchaka:locale-modifiers

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 30, 2025

Copy link
Copy Markdown
Member

@serhiy-storchaka

Copy link
Copy Markdown
Member Author

Comment thread Lib/locale.py
Comment on lines 487 to +491
if modifier == 'euro' and '.' not in code:
# Assume Latin-9 for @euro locales. This is bogus,
# since some systems may use other encodings for these
# locales. Also, we ignore other modifiers.
return code, 'iso-8859-15'
# locales.
return code + '@euro', 'ISO8859-15'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This may be a dead code, because normalize() above adds encoding.

@malemburg malemburg 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.

A few small change requests, but otherwise this looks good. Thanks, @serhiy-storchaka

Comment thread Lib/locale.py Outdated
@@ -487,11 +487,16 @@ def _parse_localename(localename):
if modifier == 'euro' and '.' not in code:
# Assume Latin-9 for @euro locales. This is bogus,
# since some systems may use other encodings for these

@malemburg malemburg Aug 3, 2025

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.

Please rewrite the comment to:

# Assume ISO8859-15 for @euro locales. Do note that some systems
# may use other encodings for these locales, so this may not always
# be correct.

Comment thread Lib/locale.py
if modifier == 'euro':
if '.' not in code:
return code + '.ISO8859-15'
return code + '.ISO8859-15@euro'

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.

Please add a comment to this section stating that Linux appears to require keeping the "@euro" modifier in place, even when using the ".ISO8859-15" encoding.

# Ignore one letter locale mappings (except for 'c')
if len(locale) == 1 and locale != 'c':
continue
if '@' in locale and '@' not in alias:

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.

Please add a comment explaining why this is done (to make glibc on Linux happy)

@serhiy-storchaka serhiy-storchaka changed the title gh-87281: Fix support for locales with modifiers gh-137729: Fix support for locales with @-modifiers Aug 13, 2025
@serhiy-storchaka

Copy link
Copy Markdown
Member Author

@malemburg, please look at this PR again. I added documentation and comments as you suggested.

@serhiy-storchaka serhiy-storchaka marked this pull request as ready for review August 14, 2025 06:01

@malemburg malemburg 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.

LGTM. Thanks, @serhiy-storchaka

@serhiy-storchaka serhiy-storchaka merged commit 0c8fecc into python:main Aug 18, 2025
79 of 81 checks passed
@serhiy-storchaka serhiy-storchaka deleted the locale-modifiers branch August 18, 2025 07:11
@bedevere-bot

Copy link
Copy Markdown

Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants