]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #20033: makelocalealias.py now works with non-ASCII locales and produces
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 23 Dec 2013 16:56:08 +0000 (18:56 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 23 Dec 2013 16:56:08 +0000 (18:56 +0200)
the same result as in 2.x.

Tools/i18n/makelocalealias.py

index 68544ac27b9b210978de0800090b99f0f10da518..3445ec8020ac38c0fc5ba4c0ff8d55a474d30976 100644 (file)
@@ -13,8 +13,8 @@ LOCALE_ALIAS = '/usr/share/X11/locale/locale.alias'
 
 def parse(filename):
 
-    f = open(filename)
-    lines = f.read().splitlines()
+    with open(filename, encoding='latin1') as f:
+        lines = list(f)
     data = {}
     for line in lines:
         line = line.strip()
@@ -47,15 +47,15 @@ def parse(filename):
 def pprint(data):
     items = sorted(data.items())
     for k, v in items:
-        print('    %-40s%r,' % ('%r:' % k, v))
+        print('    %-40s%a,' % ('%a:' % k, v))
 
 def print_differences(data, olddata):
     items = sorted(olddata.items())
     for k, v in items:
         if k not in data:
-            print('#    removed %r' % k)
+            print('#    removed %a' % k)
         elif olddata[k] != data[k]:
-            print('#    updated %r -> %r to %r' % \
+            print('#    updated %a -> %a to %a' % \
                   (k, olddata[k], data[k]))
         # Additions are not mentioned