From: Robert Bradshaw Date: Thu, 22 Oct 2009 05:34:50 +0000 (-0700) Subject: Fix comparison type deduction. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3c0c4d0648496a7c58bbb74de5891a85820cda36;p=cython.git Fix comparison type deduction. --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 8ec30f9f..5a532955 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -5132,9 +5132,11 @@ class CmpNode(object): if new_common_type is None: # fall back to generic type compatibility tests - if type1 == type2 or type1.assignable_from(type2): + if type1 == type2: new_common_type = type1 - elif type2.assignable_from(type1): + elif not type2 is py_object_type and type1.assignable_from(type2): + new_common_type = type1 + elif not type1 is py_object_type and type2.assignable_from(type1): new_common_type = type2 elif type1.is_pyobject and type2.is_pyobject: new_common_type = py_object_type diff --git a/tests/run/cmp.pyx b/tests/run/cmp.pyx index 7cb9c05e..0cffec98 100644 --- a/tests/run/cmp.pyx +++ b/tests/run/cmp.pyx @@ -33,3 +33,10 @@ def single_c(int a, int b): def cascaded_c(double a, double b, double c): return a < b < c + +def typed_cmp(list L): + """ + >>> typed_cmp([1,2,3]) + (False, False) + """ + return L is Ellipsis, Ellipsis is L