Commit 46c6b203 authored by Guido van Rossum's avatar Guido van Rossum

Patch by Mozhe Zadka, for __contains__ (overloading 'in'). This

patches PySequence_Contains() to check for a valid sq_contains field.
More to follow.
parent cecb27a4
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment