]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-133967: Do not normalize locale name 'C.UTF-8' to 'en_US.UTF-8' (GH-135347...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 11 Jun 2025 09:43:38 +0000 (11:43 +0200)
committerGitHub <noreply@github.com>
Wed, 11 Jun 2025 09:43:38 +0000 (12:43 +0300)
(cherry picked from commit 0f866cbfefd797b4dae25962457c5579bb90dde5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/locale.py
Lib/test/test_locale.py
Misc/NEWS.d/next/Library/2025-06-10-16-11-00.gh-issue-133967.P0c24q.rst [new file with mode: 0644]
Tools/i18n/makelocalealias.py

index 213d5e93418cfb556d158b7e918b04c8d07bb2d5..db6d0abb26b6ddb8ab0bdb5a9c33dc9690dc8ba9 100644 (file)
@@ -878,6 +878,10 @@ del k, v
 #    updated 'sr@latn' -> 'sr_CS.UTF-8@latin' to 'sr_RS.UTF-8@latin'
 #    removed 'univ'
 #    removed 'universal'
+#
+# SS 2025-06-10:
+# Remove 'c.utf8' -> 'en_US.UTF-8' because 'en_US.UTF-8' does not exist
+# on all platforms.
 
 locale_alias = {
     'a3':                                   'az_AZ.KOI8-C',
@@ -957,7 +961,6 @@ locale_alias = {
     'c.ascii':                              'C',
     'c.en':                                 'C',
     'c.iso88591':                           'en_US.ISO8859-1',
-    'c.utf8':                               'en_US.UTF-8',
     'c_c':                                  'C',
     'c_c.c':                                'C',
     'ca':                                   'ca_ES.ISO8859-1',
index 00e93d8e78443d47b7e9c833f633c76e54802927..fe9b4ad1abc9750c29775d763f26d31e2a965234 100644 (file)
@@ -388,6 +388,10 @@ class NormalizeTest(unittest.TestCase):
         self.check('c', 'C')
         self.check('posix', 'C')
 
+    def test_c_utf8(self):
+        self.check('c.utf8', 'C.UTF-8')
+        self.check('C.UTF-8', 'C.UTF-8')
+
     def test_english(self):
         self.check('en', 'en_US.ISO8859-1')
         self.check('EN', 'en_US.ISO8859-1')
diff --git a/Misc/NEWS.d/next/Library/2025-06-10-16-11-00.gh-issue-133967.P0c24q.rst b/Misc/NEWS.d/next/Library/2025-06-10-16-11-00.gh-issue-133967.P0c24q.rst
new file mode 100644 (file)
index 0000000..1976981
--- /dev/null
@@ -0,0 +1 @@
+Do not normalize :mod:`locale` name 'C.UTF-8' to 'en_US.UTF-8'.
index b407a8a643be7c047d93c21405cb7ae0295ca10f..02af1caff7d499813f8846c50422617d5e783ea1 100755 (executable)
@@ -140,6 +140,9 @@ if __name__ == '__main__':
     data = locale.locale_alias.copy()
     data.update(parse_glibc_supported(args.glibc_supported))
     data.update(parse(args.locale_alias))
+    # Hardcode 'c.utf8' -> 'C.UTF-8' because 'en_US.UTF-8' does not exist
+    # on all platforms.
+    data['c.utf8'] = 'C.UTF-8'
     while True:
         # Repeat optimization while the size is decreased.
         n = len(data)