From 81a1f7fdc4355cc3ae328dc45a8907a061fb7764 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 3 Jan 2013 21:55:20 +0100 Subject: [PATCH] fix comparison of single character unicode literals --HG-- extra : rebase_source : 5e91ffb0a20724dc92084bb68288cb6000814dca --- Cython/Compiler/ExprNodes.py | 5 ++++- tests/run/py_ucs4_type.pyx | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 5604aa5..0990da8 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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 diff --git a/tests/run/py_ucs4_type.pyx b/tests/run/py_ucs4_type.pyx index a5d6f37..539ceca 100644 --- a/tests/run/py_ucs4_type.pyx +++ b/tests/run/py_ucs4_type.pyx @@ -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 -- 2.7.4