fix comparison of single character unicode literals
authorStefan Behnel <stefan_ml@behnel.de>
Thu, 3 Jan 2013 20:55:20 +0000 (21:55 +0100)
committerStefan Behnel <stefan_ml@behnel.de>
Thu, 3 Jan 2013 20:55:20 +0000 (21:55 +0100)
--HG--
extra : rebase_source : 5e91ffb0a20724dc92084bb68288cb6000814dca

Cython/Compiler/ExprNodes.py
tests/run/py_ucs4_type.pyx

index 5604aa5..0990da8 100755 (executable)
@@ -8696,7 +8696,10 @@ class CmpNode(object):
                 return type2
         elif type1_can_be_int:
             if type2_can_be_int:
-                return PyrexTypes.c_uchar_type
+                if Builtin.unicode_type in (type1, type2):
+                    return PyrexTypes.c_py_ucs4_type
+                else:
+                    return PyrexTypes.c_uchar_type
 
         return None
 
index a5d6f37..539ceca 100644 (file)
@@ -29,6 +29,14 @@ def compare_klingon():
     print(char_KLINGON == u'B')
 
 
+def single_uchar_compare():
+    """
+    >>> single_uchar_compare()
+    """
+    assert u'\u0100' < u'\u0101'
+    assert u'\u0101' > u'\u0100'
+
+
 from cpython.unicode cimport PyUnicode_FromOrdinal
 import sys