Alexander Belopolsky <belopol...@users.sourceforge.net> added the comment:
On Mon, Nov 29, 2010 at 1:21 PM, Marc-Andre Lemburg
<rep...@bugs.python.org> wrote:
..
> BTW: You appear to have a comma appended to the constant, that doesn't
> belong there:
>
> +# Placeholder for a missing codepoint
> +MISSING_CODE = -1,
> +
>
> Perhaps that's causing the second error you are seeing.
No, that comma was a left-over from the attempt to fix the
mac_chinsimp error. The trace that I reported was generated with
MISSING_CODE = -1. I am replacing the patch.
Is it ok to commit a partial fix? It may take longer to fix the mac error.
----------
Added file: http://bugs.python.org/file19874/issue10552a.diff
_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10552>
_______________________________________
Index: Tools/unicode/gencodec.py
===================================================================
--- Tools/unicode/gencodec.py (revision 86837)
+++ Tools/unicode/gencodec.py (working copy)
@@ -34,6 +34,9 @@
# Standard undefined Unicode code point
UNI_UNDEFINED = chr(0xFFFE)
+# Placeholder for a missing codepoint
+MISSING_CODE = -1
+
mapRE = re.compile('((?:0x[0-9a-fA-F]+\+?)+)'
'\s+'
'((?:(?:0x[0-9a-fA-Z]+|<[A-Za-z]+>)\+?)*)'
@@ -52,7 +55,7 @@
"""
if not codes:
- return None
+ return MISSING_CODE
l = codes.split('+')
if len(l) == 1:
return int(l[0],16)
@@ -60,8 +63,8 @@
try:
l[i] = int(l[i],16)
except ValueError:
- l[i] = None
- l = [x for x in l if x is not None]
+ l[i] = MISSING_CODE
+ l = [x for x in l if x != MISSING_CODE]
if len(l) == 1:
return l[0]
else:
@@ -113,7 +116,7 @@
# mappings to None for the rest
if len(identity) >= len(unmapped):
for enc in unmapped:
- enc2uni[enc] = (None, "")
+ enc2uni[enc] = (MISSING_CODE, "")
enc2uni['IDENTITY'] = 256
return enc2uni
@@ -211,7 +214,7 @@
(mapkey, mapcomment) = mapkey
if isinstance(mapvalue, tuple):
(mapvalue, mapcomment) = mapvalue
- if mapkey is None:
+ if mapkey == MISSING_CODE:
continue
table[mapkey] = (mapvalue, mapcomment)
if mapkey > maxkey:
@@ -223,11 +226,11 @@
# Create table code
for key in range(maxkey + 1):
if key not in table:
- mapvalue = None
+ mapvalue = MISSING_CODE
mapcomment = 'UNDEFINED'
else:
mapvalue, mapcomment = table[key]
- if mapvalue is None:
+ if mapvalue == MISSING_CODE:
mapchar = UNI_UNDEFINED
else:
if isinstance(mapvalue, tuple):
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com