From 3e57b52bb800b8d001092490f2a658271d613d6d Mon Sep 17 00:00:00 2001 From: Thomas Wouters Date: Tue, 28 Aug 2007 23:07:26 +0000 Subject: Fix buglet in sliceobjects, they were not returning Py_NotImplemented when compared against something other than sliceobjects. --- Lib/test/test_slice.py | 3 +++ Objects/sliceobject.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/Lib/test/test_slice.py b/Lib/test/test_slice.py index 4d89aa6..97b3084 100644 --- a/Lib/test/test_slice.py +++ b/Lib/test/test_slice.py @@ -26,6 +26,9 @@ class SliceTest(unittest.TestCase): s3 = slice(1, 2, 4) self.assertEqual(s1, s2) self.assertNotEqual(s1, s3) + self.assertNotEqual(s1, None) + self.assertNotEqual(s1, (1, 2, 3)) + self.assertNotEqual(s1, "") class Exc(Exception): pass diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c index 498172d..eb66c79 100644 --- a/Objects/sliceobject.c +++ b/Objects/sliceobject.c @@ -286,6 +286,11 @@ slice_richcompare(PyObject *v, PyObject *w, int op) PyObject *t2; PyObject *res; + if (!PySlice_Check(v) || !PySlice_Check(w)) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + if (v == w) { /* XXX Do we really need this shortcut? There's a unit test for it, but is that fair? */ -- cgit v0.12