1
Vote

comparison is not always compatible with CPython

description

On CPython this code prints "Pass" and on IronPython it prints "Fail".
 
 
import bisect
 
class CmpErr:
"Dummy element that always raises an error during comparison"
def __cmp__(self, other):
    raise ZeroDivisionError
seq = [CmpErr(), CmpErr(), CmpErr()]
 
try:
bisect.bisect_left(seq, 10)
except ZeroDivisionError:
print "Pass"
else:
print "Fail"
 
It looks like the comparison code that is generated is not doing the correct thing compared to the rich comparison in CPython.

comments