diff -r ad56dff3602f Tools/unicode/mkstringprep.py --- a/Tools/unicode/mkstringprep.py Tue May 28 16:27:08 2013 +0300 +++ b/Tools/unicode/mkstringprep.py Tue May 28 20:40:16 2013 +0300 @@ -1,4 +1,5 @@ -import re, unicodedata, sys +import re, sys +from unicodedata import ucd_3_2_0 as unicodedata if sys.maxunicode == 65535: raise RuntimeError("need UCS-4 Python") @@ -37,7 +38,10 @@ tuple.append((prev,prev+span+1)) else: single.append(prev) - tuple = " + ".join(["list(range(%d,%d))" % t for t in tuple]) + if not single and len(tuple) == 1: + tuple = "range(%d,%d)" % tuple[0] + else: + tuple = " + ".join("list(range(%d,%d))" % t for t in tuple) if not single: return "set(%s)" % tuple if not tuple: @@ -113,7 +117,7 @@ and mappings, for which a mapping function is provided. \"\"\" -import unicodedata +from unicodedata import ucd_3_2_0 as unicodedata """) print("assert unicodedata.unidata_version == %s" % repr(unicodedata.unidata_version)) @@ -173,15 +177,15 @@ b3_exceptions = {} for k,v in table_b2.items(): - if map(ord, unichr(k).lower()) != v: - b3_exceptions[k] = u"".join(map(unichr,v)) + if list(map(ord, chr(k).lower())) != v: + b3_exceptions[k] = "".join(map(chr,v)) b3 = sorted(b3_exceptions.items()) print(""" b3_exceptions = {""") -for i,(k,v) in enumerate(b3): - print("0x%x:%s," % (k, repr(v)), end=' ') +for i, kv in enumerate(b3): + print("0x%x:%a," % kv, end=' ') if i % 4 == 3: print() print("}") @@ -224,7 +228,7 @@ def map_table_b2(a): al = map_table_b3(a) b = unicodedata.normalize("NFKC", al) - bl = u"".join([map_table_b3(ch) for ch in b]) + bl = "".join([map_table_b3(ch) for ch in b]) c = unicodedata.normalize("NFKC", bl) if b != c: return c @@ -240,7 +244,7 @@ print(""" def in_table_c11(code): - return code == u" " + return code == " " """) # C.1.2 is the rest of all space characters @@ -254,7 +258,7 @@ print(""" def in_table_c12(code): - return unicodedata.category(code) == "Zs" and code != u" " + return unicodedata.category(code) == "Zs" and code != " " def in_table_c11_c12(code): return unicodedata.category(code) == "Zs"