[pypy-commit] pypy default: test, fix for missing __ne__ on slices
mattip
pypy.commits at gmail.com
Thu Aug 24 16:08:49 EDT 2017
Author: Matti Picus <matti.picus at gmail.com>
Branch:
Changeset: r92259:5a7118bbfee9
Date: 2017-08-24 23:07 +0300
http://bitbucket.org/pypy/pypy/changeset/5a7118bbfee9/
Log: test, fix for missing __ne__ on slices
diff --git a/pypy/objspace/std/sliceobject.py b/pypy/objspace/std/sliceobject.py
--- a/pypy/objspace/std/sliceobject.py
+++ b/pypy/objspace/std/sliceobject.py
@@ -132,6 +132,18 @@
else:
return space.w_False
+ def descr_ne(self, space, w_other):
+ if space.is_w(self, w_other):
+ return space.w_False
+ if not isinstance(w_other, W_SliceObject):
+ return space.w_NotImplemented
+ if space.eq_w(self.w_start, w_other.w_start) and \
+ space.eq_w(self.w_stop, w_other.w_stop) and \
+ space.eq_w(self.w_step, w_other.w_step):
+ return space.w_False
+ else:
+ return space.w_True
+
def descr_lt(self, space, w_other):
if space.is_w(self, w_other):
return space.w_False # see comments in descr_eq()
@@ -177,6 +189,7 @@
__reduce__ = gateway.interp2app(W_SliceObject.descr__reduce__),
__eq__ = gateway.interp2app(W_SliceObject.descr_eq),
+ __ne__ = gateway.interp2app(W_SliceObject.descr_ne),
__lt__ = gateway.interp2app(W_SliceObject.descr_lt),
start = slicewprop('w_start'),
diff --git a/pypy/objspace/std/test/test_sliceobject.py b/pypy/objspace/std/test/test_sliceobject.py
--- a/pypy/objspace/std/test/test_sliceobject.py
+++ b/pypy/objspace/std/test/test_sliceobject.py
@@ -94,6 +94,7 @@
slice1 = slice(1, 2, 3)
slice2 = slice(1, 2, 3)
assert slice1 == slice2
+ assert not slice1 != slice2
slice2 = slice(1, 2)
assert slice1 != slice2
More information about the pypy-commit
mailing list