Skip to content

Commit 0f866cb

Browse files
gh-133967: Do not normalize locale name 'C.UTF-8' to 'en_US.UTF-8' (#135347)
1 parent ff2b5f4 commit 0f866cb

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

Lib/locale.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,10 @@ def getpreferredencoding(do_setlocale=True):
883883
# updated 'sr@latn' -> 'sr_CS.UTF-8@latin' to 'sr_RS.UTF-8@latin'
884884
# removed 'univ'
885885
# removed 'universal'
886+
#
887+
# SS 2025-06-10:
888+
# Remove 'c.utf8' -> 'en_US.UTF-8' because 'en_US.UTF-8' does not exist
889+
# on all platforms.
886890

887891
locale_alias = {
888892
'a3': 'az_AZ.KOI8-C',
@@ -962,7 +966,6 @@ def getpreferredencoding(do_setlocale=True):
962966
'c.ascii': 'C',
963967
'c.en': 'C',
964968
'c.iso88591': 'en_US.ISO8859-1',
965-
'c.utf8': 'en_US.UTF-8',
966969
'c_c': 'C',
967970
'c_c.c': 'C',
968971
'ca': 'ca_ES.ISO8859-1',

Lib/test/test_locale.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ def test_c(self):
387387
self.check('c', 'C')
388388
self.check('posix', 'C')
389389

390+
def test_c_utf8(self):
391+
self.check('c.utf8', 'C.UTF-8')
392+
self.check('C.UTF-8', 'C.UTF-8')
393+
390394
def test_english(self):
391395
self.check('en', 'en_US.ISO8859-1')
392396
self.check('EN', 'en_US.ISO8859-1')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Do not normalize :mod:`locale` name 'C.UTF-8' to 'en_US.UTF-8'.

Tools/i18n/makelocalealias.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ def check(data):
140140
data = locale.locale_alias.copy()
141141
data.update(parse_glibc_supported(args.glibc_supported))
142142
data.update(parse(args.locale_alias))
143+
# Hardcode 'c.utf8' -> 'C.UTF-8' because 'en_US.UTF-8' does not exist
144+
# on all platforms.
145+
data['c.utf8'] = 'C.UTF-8'
143146
while True:
144147
# Repeat optimization while the size is decreased.
145148
n = len(data)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy