Title: Support locales with @-modifiers · Issue #137729 · python/cpython · GitHub
Open Graph Title: Support locales with @-modifiers · Issue #137729 · python/cpython
X Title: Support locales with @-modifiers · Issue #137729 · python/cpython
Description: 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 ...
Open Graph Description: 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...
X Description: 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...
Opengraph URL: https://github.com/python/cpython/issues/137729
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support locales with @-modifiers","articleBody":"# Feature or enhancement\n\nCurrently, `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).\n\nAccordingly, `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.\n\nSee also #87281.\n\nThe 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.\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-137253\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2025-08-13T18:31:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/137729/cpython/issues/137729"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b0e23ab8-2f72-3fb0-2335-d2c6cf20f896 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E2EA:3C193B:3E90E8:54C006:6A524960 |
| html-safe-nonce | d418532eff72c0cd878e6e44618e4f01aa24cc7a2c78ef0c350fbab193680b94 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMkVBOjNDMTkzQjozRTkwRTg6NTRDMDA2OjZBNTI0OTYwIiwidmlzaXRvcl9pZCI6IjYyMjA1NTE5OTczMDY4NDk2MzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ffb50e2a7875f78b070392d2452aa8a87f70b082d0eab6933b985a44d7174788 |
| hovercard-subject-tag | issue:3319437595 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/137729/issue_layout |
| twitter:image | https://opengraph.githubassets.com/20e7952b4fda1fae6bc78851ae44d8190fbe6d2e3418e96b58f8920e46b93744/python/cpython/issues/137729 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/20e7952b4fda1fae6bc78851ae44d8190fbe6d2e3418e96b58f8920e46b93744/python/cpython/issues/137729 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | serhiy-storchaka |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width