Commit 6fe1da39 authored by Stefan Behnel's avatar Stefan Behnel

merge

parents b67f30be 9cece7db
...@@ -5132,27 +5132,29 @@ class CmpNode(object): ...@@ -5132,27 +5132,29 @@ class CmpNode(object):
if new_common_type is None: if new_common_type is None:
# fall back to generic type compatibility tests # fall back to generic type compatibility tests
if type1 == type2 or type1.assignable_from(type2): if type1 == type2:
new_common_type = type1 new_common_type = type1
elif 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: elif type1.is_pyobject or type2.is_pyobject:
if type2.is_numeric or type2.is_string: if type2.is_numeric or type2.is_string:
if operand2.check_for_coercion_error(type1): if operand2.check_for_coercion_error(type1):
new_common_type = error_type new_common_type = error_type
else: else:
new_common_type = type1 new_common_type = py_object_type
elif type1.is_numeric or type1.is_string: elif type1.is_numeric or type1.is_string:
if operand1.check_for_coercion_error(type2): if operand1.check_for_coercion_error(type2):
new_common_type = error_type new_common_type = error_type
else: 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: else:
# one Python type and one non-Python type, not assignable # one Python type and one non-Python type, not assignable
self.invalid_types_error(operand1, op, operand2) self.invalid_types_error(operand1, op, operand2)
new_common_type = error_type new_common_type = error_type
elif type1.assignable_from(type2):
new_common_type = type1
elif type2.assignable_from(type1):
new_common_type = type2
else: else:
# C types that we couldn't handle up to here are an error # C types that we couldn't handle up to here are an error
self.invalid_types_error(operand1, op, operand2) self.invalid_types_error(operand1, op, operand2)
......
...@@ -33,3 +33,43 @@ def single_c(int a, int b): ...@@ -33,3 +33,43 @@ def single_c(int a, int b):
def cascaded_c(double a, double b, double c): def cascaded_c(double a, double b, double c):
return a < b < c return a < b < c
def typed_cmp(list L):
"""
>>> typed_cmp([1,2,3])
False
False
False
False
"""
print L is Ellipsis
print Ellipsis is L
print 1 == L
print L == 1.5
def pointer_cmp():
"""
>>> pointer_cmp()
True
False
True
"""
cdef int* a = NULL
cdef double* b = NULL
cdef double** c = NULL
print a is NULL
print b is not NULL
print c == NULL
def c_cmp(double a, int b, long c):
"""
>>> c_cmp(1, 2, 3)
True
>>> c_cmp(1.5, 2, 2)
True
>>> c_cmp(1.5, 2, 0)
False
>>> c_cmp(1, 1, 3)
False
"""
return a < b <= c
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment