Author: Antonio Cuni <[email protected]>
Branch:
Changeset: r53069:719543208434
Date: 2012-03-01 17:52 +0100
http://bitbucket.org/pypy/pypy/changeset/719543208434/
Log: in cpython array.array define tp_richcompare, not tp_compare; do the
equivalent for pypy
diff --git a/pypy/module/array/interp_array.py
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -583,14 +583,32 @@
raise OperationError(space.w_ValueError, space.wrap(msg))
# Compare methods
- def cmp__Array_ANY(space, self, other):
+ def _cmp_impl(space, self, other, space_fn):
if isinstance(other, W_ArrayBase):
w_lst1 = array_tolist__Array(space, self)
w_lst2 = space.call_method(other, 'tolist')
- return space.cmp(w_lst1, w_lst2)
+ return space_fn(w_lst1, w_lst2)
else:
return space.w_NotImplemented
+ def eq__Array_ANY(space, self, other):
+ return _cmp_impl(space, self, other, space.eq)
+
+ def ne__Array_ANY(space, self, other):
+ return _cmp_impl(space, self, other, space.ne)
+
+ def lt__Array_ANY(space, self, other):
+ return _cmp_impl(space, self, other, space.lt)
+
+ def le__Array_ANY(space, self, other):
+ return _cmp_impl(space, self, other, space.le)
+
+ def gt__Array_ANY(space, self, other):
+ return _cmp_impl(space, self, other, space.gt)
+
+ def ge__Array_ANY(space, self, other):
+ return _cmp_impl(space, self, other, space.ge)
+
# Misc methods
def buffer__Array(space, self):
diff --git a/pypy/module/array/test/test_array.py
b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -536,11 +536,11 @@
assert (a >= c) is False
assert (c >= a) is True
- assert cmp(a, a) == 0
- assert cmp(a, b) == 0
- assert cmp(a, c) < 0
- assert cmp(b, a) == 0
- assert cmp(c, a) > 0
+ assert a == a
+ assert a == b
+ assert a < c
+ assert b == a
+ assert c > a
def test_reduce(self):
import pickle
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit