From 2e864668898bb4714608bbe1a0c487da8eb52e2c Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Wed, 21 Oct 2009 23:18:20 -0700 Subject: [PATCH] More comparison fixes. --- Cython/Compiler/ExprNodes.py | 12 ++++-------- tests/run/cmp.pyx | 10 ++++++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 5a532955..5c3670b8 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -5134,23 +5134,19 @@ class CmpNode(object): # fall back to generic type compatibility tests if type1 == type2: new_common_type = 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 elif type1.is_pyobject or type2.is_pyobject: if type2.is_numeric or type2.is_string: if operand2.check_for_coercion_error(type1): new_common_type = error_type else: - new_common_type = type1 + new_common_type = py_object_type elif type1.is_numeric or type1.is_string: if operand1.check_for_coercion_error(type2): new_common_type = error_type else: - new_common_type = type2 + new_common_type = py_object_type + elif py_object_type.assignable_from(type1) and py_object_type.assignable_from(type2): + new_common_type = py_object_type else: # one Python type and one non-Python type, not assignable self.invalid_types_error(operand1, op, operand2) diff --git a/tests/run/cmp.pyx b/tests/run/cmp.pyx index 0cffec98..ecc30d24 100644 --- a/tests/run/cmp.pyx +++ b/tests/run/cmp.pyx @@ -37,6 +37,12 @@ def cascaded_c(double a, double b, double c): def typed_cmp(list L): """ >>> typed_cmp([1,2,3]) - (False, False) + False + False + False + False """ - return L is Ellipsis, Ellipsis is L + print L is Ellipsis + print Ellipsis is L + print 1 == L + print L == 1.5 -- 2.26.2