João Bernardo <[email protected]> added the comment:
Using my poor grep abilities I found that on Objects/typeobject.c
(I replaced some declarations/error checking from the code with ...)
static int
slot_sq_contains(PyObject *self, PyObject *value) {
...
func = lookup_maybe(self, "__contains__", &contains_str);
if (func != NULL) {
...
res = PyObject_Call(func, args, NULL);
...
if (res != NULL) {
result = PyObject_IsTrue(res);
Py_DECREF(res);
}
}
else if (! PyErr_Occurred()) {
/* Possible results: -1 and 1 */
result = (int)_PySequence_IterSearch(self, value,
PY_ITERSEARCH_CONTAINS);
}
}
I don't know if I'm in the right place, but the function returns `int` and
evaluates the result to 1 or 0 if __contains__ is found.
I also don't know what SQSLOT means, but unlike the other operators (which are
defined as TPSLOT), `slot_sq_contains` is a function returning "int" while
`slot_tp_richcompare` returns "PyObject *".
Why is that defined that way?
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue13667>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com