@@ -375,12 +375,14 @@ def _replace_encoding(code, encoding):
375375def _append_modifier (code , modifier ):
376376 if modifier == 'euro' :
377377 if '.' not in code :
378- return code + '.ISO8859-15'
378+ # Linux appears to require keeping the "@euro" modifier in place,
379+ # even when using the ".ISO8859-15" encoding.
380+ return code + '.ISO8859-15@euro'
379381 _ , _ , encoding = code .partition ('.' )
380- if encoding in ( 'ISO8859-15' , ' UTF-8') :
382+ if encoding == ' UTF-8' :
381383 return code
382384 if encoding == 'ISO8859-1' :
383- return _replace_encoding (code , 'ISO8859-15' )
385+ code = _replace_encoding (code , 'ISO8859-15' )
384386 return code + '@' + modifier
385387
386388def normalize (localename ):
@@ -485,13 +487,18 @@ def _parse_localename(localename):
485487 # Deal with locale modifiers
486488 code , modifier = code .split ('@' , 1 )
487489 if modifier == 'euro' and '.' not in code :
488- # Assume Latin-9 for @euro locales. This is bogus,
489- # since some systems may use other encodings for these
490- # locales. Also, we ignore other modifiers.
491- return code , 'iso-8859-15'
490+ # Assume ISO8859-15 for @euro locales. Do note that some systems
491+ # may use other encodings for these locales, so this may not always
492+ # be correct.
493+ return code + '@euro' , 'ISO8859-15'
494+ else :
495+ modifier = ''
492496
493497 if '.' in code :
494- return tuple (code .split ('.' )[:2 ])
498+ code , encoding = code .split ('.' )[:2 ]
499+ if modifier :
500+ code += '@' + modifier
501+ return code , encoding
495502 elif code == 'C' :
496503 return None , None
497504 elif code == 'UTF-8' :
@@ -516,7 +523,14 @@ def _build_localename(localetuple):
516523 if encoding is None :
517524 return language
518525 else :
519- return language + '.' + encoding
526+ if '@' in language :
527+ language , modifier = language .split ('@' , 1 )
528+ else :
529+ modifier = ''
530+ localename = language + '.' + encoding
531+ if modifier :
532+ localename += '@' + modifier
533+ return localename
520534 except (TypeError , ValueError ):
521535 raise TypeError ('Locale must be None, a string, or an iterable of '
522536 'two strings -- language code, encoding.' ) from None
@@ -888,6 +902,12 @@ def getpreferredencoding(do_setlocale=True):
888902# SS 2025-06-10:
889903# Remove 'c.utf8' -> 'en_US.UTF-8' because 'en_US.UTF-8' does not exist
890904# on all platforms.
905+ #
906+ # SS 2025-07-30:
907+ # Remove conflicts with GNU libc.
908+ #
909+ # removed 'el_gr@euro'
910+ # removed 'uz_uz@cyrillic'
891911
892912locale_alias = {
893913 'a3' : 'az_AZ.KOI8-C' ,
@@ -1021,7 +1041,6 @@ def getpreferredencoding(do_setlocale=True):
10211041 'el' : 'el_GR.ISO8859-7' ,
10221042 'el_cy' : 'el_CY.ISO8859-7' ,
10231043 'el_gr' : 'el_GR.ISO8859-7' ,
1024- 'el_gr@euro' : 'el_GR.ISO8859-15' ,
10251044 'en' : 'en_US.ISO8859-1' ,
10261045 'en_ag' : 'en_AG.UTF-8' ,
10271046 'en_au' : 'en_AU.ISO8859-1' ,
@@ -1456,7 +1475,6 @@ def getpreferredencoding(do_setlocale=True):
14561475 'ur_pk' : 'ur_PK.CP1256' ,
14571476 'uz' : 'uz_UZ.UTF-8' ,
14581477 'uz_uz' : 'uz_UZ.UTF-8' ,
1459- 'uz_uz@cyrillic' : 'uz_UZ.UTF-8' ,
14601478 've' : 've_ZA.UTF-8' ,
14611479 've_za' : 've_ZA.UTF-8' ,
14621480 'vi' : 'vi_VN.TCVN' ,
0 commit comments