]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix buglet in sliceobjects, they were not returning Py_NotImplemented when
authorThomas Wouters <thomas@python.org>
Tue, 28 Aug 2007 23:07:26 +0000 (23:07 +0000)
committerThomas Wouters <thomas@python.org>
Tue, 28 Aug 2007 23:07:26 +0000 (23:07 +0000)
compared against something other than sliceobjects.

Lib/test/test_slice.py
Objects/sliceobject.c

index 4d89aa6a397f1f972663f1504973be4c76bab146..97b308460172fdb3da84f522f910a18c148ba89f 100644 (file)
@@ -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
index 498172d5c4ac64fbf304061e40d02dcc468ae3b2..eb66c79b572136b1ef02e69776794715a5b33840 100644 (file)
@@ -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? */