[pypy-svn] r59016 - pypy/dist/pypy/module/unicodedata

iko at codespeak.net iko at codespeak.net
Sun Oct 12 13:35:05 CEST 2008


Author: iko
Date: Sun Oct 12 13:35:03 2008
New Revision: 59016

Modified:
   pypy/dist/pypy/module/unicodedata/generate_unicodedb.py
Log:
Make sure code points exists before adding them to reverse dict



Modified: pypy/dist/pypy/module/unicodedata/generate_unicodedb.py
==============================================================================
--- pypy/dist/pypy/module/unicodedata/generate_unicodedb.py	(original)
+++ pypy/dist/pypy/module/unicodedata/generate_unicodedb.py	Sun Oct 12 13:35:03 2008
@@ -357,9 +357,12 @@
         function.append(
             "    if %d <= code <= %d: res = _charnames_%d[code-%d]" % (
             low, high, low, low))
-        f_reverse_dict.append(
-            "    for i in range(%d, %d): res[_charnames_%d[i-%d]] = i" % (
-            low, high+1, low, low))
+        f_reverse_dict.extend([
+            "    for i in range(%d, %d):" % (low, high+1),
+            "        name = _charnames_%d[i-%d]" % (low, low),
+            "        if name is not None:",
+            "            res[name] = i",
+            ])
         print >> outfile, "_charnames_%d = [" % (low,)
         for code in range(low, high + 1):
             name = table[code].name



More information about the Pypy-commit mailing list