Patch by Mozhe Zadka, for __contains__ (overloading 'in'). This
authorGuido van Rossum <guido@python.org>
Mon, 28 Feb 2000 15:01:46 +0000 (15:01 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 28 Feb 2000 15:01:46 +0000 (15:01 +0000)
patches PySequence_Contains() to check for a valid sq_contains field.
More to follow.

Objects/abstract.c

index 5ee53ee9f261c6bfaae2a01027a0d73634c8b06c..739d9d9d55ec5e0d58314e1c3ea9ddb8052de2cb 100644 (file)
@@ -1139,7 +1139,14 @@ PySequence_Contains(w, v) /* v in w */
                }
                return 0;
        }
-
+       if(PyType_HasFeature(w->ob_type, Py_TPFLAGS_HAVE_SEQUENCE_IN)) {
+               sq = w->ob_type->tp_as_sequence;
+               if(sq != NULL && sq->sq_contains != NULL)
+                       return (*sq->sq_contains)(w, v);
+       }
+       
+       /* If there is no better way to check whether an item is is contained,
+          do it the hard way */
        sq = w->ob_type->tp_as_sequence;
        if (sq == NULL || sq->sq_item == NULL) {
                PyErr_SetString(PyExc_TypeError,