More comparison fixes.
authorRobert Bradshaw <robertwb@math.washington.edu>
Thu, 22 Oct 2009 06:18:20 +0000 (23:18 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Thu, 22 Oct 2009 06:18:20 +0000 (23:18 -0700)
Cython/Compiler/ExprNodes.py
tests/run/cmp.pyx

index 5a532955a5d8991026153f8fc37e952967b150ae..5c3670b8a31d9e667fa47cf00239232982701237 100644 (file)
@@ -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)
index 0cffec98f387000a78cfbad9ffad4f47a233dbd3..ecc30d249b388a61a1cde24123711902dc5b43a3 100644 (file)
@@ -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