There was an error while loading. Please reload this page.
1 parent ed03b41 commit 3e57b52Copy full SHA for 3e57b52
2 files changed
Lib/test/test_slice.py
@@ -26,6 +26,9 @@ def test_cmp(self):
26
s3 = slice(1, 2, 4)
27
self.assertEqual(s1, s2)
28
self.assertNotEqual(s1, s3)
29
+ self.assertNotEqual(s1, None)
30
+ self.assertNotEqual(s1, (1, 2, 3))
31
+ self.assertNotEqual(s1, "")
32
33
class Exc(Exception):
34
pass
Objects/sliceobject.c
@@ -286,6 +286,11 @@ slice_richcompare(PyObject *v, PyObject *w, int op)
286
PyObject *t2;
287
PyObject *res;
288
289
+ if (!PySlice_Check(v) || !PySlice_Check(w)) {
290
+ Py_INCREF(Py_NotImplemented);
291
+ return Py_NotImplemented;
292
+ }
293
+
294
if (v == w) {
295
/* XXX Do we really need this shortcut?
296
There's a unit test for it, but is that fair? */
0 commit comments