Commit c7355fa4 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #20046: Locale alias table no longer contains entities which can be

calculated.  Generalized support of the euro modifier.
parent 78f2ccda
This diff is collapsed.
......@@ -384,6 +384,7 @@ class NormalizeTest(unittest.TestCase):
def test_english(self):
self.check('en', 'en_US.ISO8859-1')
self.check('EN', 'en_US.ISO8859-1')
self.check('en.iso88591', 'en_US.ISO8859-1')
self.check('en_US', 'en_US.ISO8859-1')
self.check('en_us', 'en_US.ISO8859-1')
self.check('en_GB', 'en_GB.ISO8859-1')
......@@ -392,7 +393,10 @@ class NormalizeTest(unittest.TestCase):
self.check('en_US:UTF-8', 'en_US.UTF-8')
self.check('en_US.ISO8859-1', 'en_US.ISO8859-1')
self.check('en_US.US-ASCII', 'en_US.ISO8859-1')
self.check('en_US.88591', 'en_US.ISO8859-1')
self.check('en_US.885915', 'en_US.ISO8859-15')
self.check('english', 'en_EN.ISO8859-1')
self.check('english_uk.ascii', 'en_GB.ISO8859-1')
def test_hyphenated_encoding(self):
self.check('az_AZ.iso88599e', 'az_AZ.ISO8859-9E')
......@@ -412,10 +416,12 @@ class NormalizeTest(unittest.TestCase):
def test_euro_modifier(self):
self.check('de_DE@euro', 'de_DE.ISO8859-15')
self.check('en_US.ISO8859-15@euro', 'en_US.ISO8859-15')
self.check('de_DE.utf8@euro', 'de_DE.UTF-8')
def test_latin_modifier(self):
self.check('be_BY.UTF-8@latin', 'be_BY.UTF-8@latin')
self.check('sr_RS.UTF-8@latin', 'sr_RS.UTF-8@latin')
self.check('sr_RS.UTF-8@latn', 'sr_RS.UTF-8@latin')
def test_valencia_modifier(self):
self.check('ca_ES.UTF-8@valencia', 'ca_ES.UTF-8@valencia')
......@@ -436,6 +442,39 @@ class NormalizeTest(unittest.TestCase):
self.check('sd_IN', 'sd_IN.UTF-8')
self.check('sd', 'sd_IN.UTF-8')
def test_euc_encoding(self):
self.check('ja_jp.euc', 'ja_JP.eucJP')
self.check('ja_jp.eucjp', 'ja_JP.eucJP')
self.check('ko_kr.euc', 'ko_KR.eucKR')
self.check('ko_kr.euckr', 'ko_KR.eucKR')
self.check('zh_cn.euc', 'zh_CN.eucCN')
self.check('zh_tw.euc', 'zh_TW.eucTW')
self.check('zh_tw.euctw', 'zh_TW.eucTW')
def test_japanese(self):
self.check('ja', 'ja_JP.eucJP')
self.check('ja.jis', 'ja_JP.JIS7')
self.check('ja.sjis', 'ja_JP.SJIS')
self.check('ja_jp', 'ja_JP.eucJP')
self.check('ja_jp.ajec', 'ja_JP.eucJP')
self.check('ja_jp.euc', 'ja_JP.eucJP')
self.check('ja_jp.eucjp', 'ja_JP.eucJP')
self.check('ja_jp.iso-2022-jp', 'ja_JP.JIS7')
self.check('ja_jp.iso2022jp', 'ja_JP.JIS7')
self.check('ja_jp.jis', 'ja_JP.JIS7')
self.check('ja_jp.jis7', 'ja_JP.JIS7')
self.check('ja_jp.mscode', 'ja_JP.SJIS')
self.check('ja_jp.pck', 'ja_JP.SJIS')
self.check('ja_jp.sjis', 'ja_JP.SJIS')
self.check('ja_jp.ujis', 'ja_JP.eucJP')
self.check('ja_jp.utf8', 'ja_JP.UTF-8')
self.check('japan', 'ja_JP.eucJP')
self.check('japanese', 'ja_JP.eucJP')
self.check('japanese-euc', 'ja_JP.eucJP')
self.check('japanese.euc', 'ja_JP.eucJP')
self.check('japanese.sjis', 'ja_JP.SJIS')
self.check('jp_jp', 'ja_JP.eucJP')
class TestMiscellaneous(unittest.TestCase):
def test_getpreferredencoding(self):
......
......@@ -44,6 +44,9 @@ Core and Builtins
Library
-------
- Issue #20046: Locale alias table no longer contains entities which can be
calculated. Generalized support of the euro modifier.
- Issue #20027: Fixed locale aliases for devanagari locales.
- Issue #20067: Tkinter variables now work when wantobjects is false.
......
......@@ -7,6 +7,7 @@
"""
import locale
import sys
# Location of the alias file
LOCALE_ALIAS = '/usr/share/X11/locale/locale.alias'
......@@ -65,9 +66,35 @@ def print_differences(data, olddata):
(k, olddata[k], data[k]))
# Additions are not mentioned
def optimize(data):
locale_alias = locale.locale_alias
locale.locale_alias = data.copy()
for k, v in data.items():
del locale.locale_alias[k]
if locale.normalize(k) != v:
locale.locale_alias[k] = v
newdata = locale.locale_alias
errors = check(data)
locale.locale_alias = locale_alias
if errors:
sys.exit(1)
return newdata
def check(data):
# Check that all alias definitions from the X11 file
# are actually mapped to the correct alias locales.
errors = 0
for k, v in data.items():
if locale.normalize(k) != v:
print('ERROR: %a -> %a != %a' % (k, locale.normalize(k), v),
file=sys.stderr)
errors += 1
return errors
if __name__ == '__main__':
data = locale.locale_alias.copy()
data.update(parse(LOCALE_ALIAS))
data = optimize(data)
print_differences(data, locale.locale_alias)
print()
print('locale_alias = {')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment