GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support locales with @-modifiers · Issue #137729 · python/cpython

Support locales with @-modifiers #137729

New issue
Copy link
New issue
Copy link
Closed
Closed
Support locales with @-modifiers#137729
Copy link
Assignees
serhiy-storchaka
Labels
3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

@serhiy-storchaka
serhiy-storchaka
opened on Aug 13, 2025
Issue body actions

Feature or enhancement

Currently, locale.getlocale() does not support locales with @-modifiers. If the current locale has an @-modifier, it will be silently dropped in the locale.getlocale() result. For example, ca_ES.utf8@valencia will result in ('ca_ES', 'UTF-8'), sr_RS.utf8@latin -- ('sr_RS', 'UTF-8'), uz_UZ.utf8@cyrillic -- ('uz_UZ', 'UTF-8'). They are different locales! The @euro modifier, the only one that handled specially, is also removed, even if locales with and without @euro can be different locales, and @euro affects collation in some locales. And for the el_gr@euro locale it returns wrong encoding ISO8859-15 (the correct encoding for this locale on Linux is ISO8859-7).

Accordingly, locale.setlocale() does not support @-modifiers if the locale is specified as a language code/encoding pair. It is supported if specify locale as string, but then the purpose of the wrapper is lost.

See also #87281.

The only way to support @-modifiers in the format compatible with this functions is to include it in the language code. So locale.getlocale() will return ('ca_ES@valencia', 'UTF-8') for locale ca_ES.utf8@valencia, and passing ('ca_ES@valencia', 'UTF-8') to locale.setlocale() will set locale to ca_ES.utf8@valencia. This is mildly breaking change, but it is better to get error in program that do not expect @ in the locale.getlocale() result than get a wrong result for that locale.

Linked PRs

  • gh-137729: Fix support for locales with @-modifiers #137253
Reacted by Michael T. Babcock

Activity

  1. serhiy-storchaka
    self-assigned this
    on Aug 13, 2025
  2. serhiy-storchaka
    added
    type-featureA feature request or enhancementA feature request or enhancement
    3.15bugs and security fixesbugs and security fixes
    on Aug 13, 2025
  3. serhiy-storchaka
    added this to Locale issues 🗺on Aug 13, 2025
  4. github-project-automation
    moved this to Todo in Locale issues 🗺on Aug 13, 2025
  5. StanFromIreland
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Aug 13, 2025
  6. serhiy-storchaka
    added a commit that references this issue on Aug 18, 2025

    gh-137729: Fix support for locales with @-modifiers (GH-137253)

    0c8fecc
  7. serhiy-storchaka
    closed this as completedon Aug 18, 2025
  8. github-project-automation
    moved this from Todo to Done in Locale issues 🗺on Aug 18, 2025
  9. Agent-Hellboy
    added a commit that references this issue on Aug 19, 2025

    pythongh-137729: Fix support for locales with @-modifiers (pythonGH-1…

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

Metadata

Metadata

Assignees

  • @serhiy-storchaka
    serhiy-storchaka

Labels

3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Projects

  • Locale issues 🗺
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.