From: Guido van Rossum Date: Wed, 8 Oct 2003 21:08:29 +0000 (+0000) Subject: SF patch #820195 by Wojtek Walczak (gminick at users.sourceforge.net): X-Git-Tag: v2.4a1~1456 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02c58f865c82021d1cde7064552d3a95301c8cc0;p=python SF patch #820195 by Wojtek Walczak (gminick at users.sourceforge.net): make obj.__contains__() returns True/False instead of 1/0. --- diff --git a/Misc/ACKS b/Misc/ACKS index 74bfbfa702..67c1cecf20 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -572,6 +572,7 @@ Frank Visser Charles Waldman Richard Walker Larry Wall +Wojtek Walczak Greg Ward Barry Warsaw Steve Waterbury diff --git a/Misc/NEWS b/Misc/NEWS index 5a8379e83d..8662f10e17 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -30,6 +30,9 @@ Core and builtins - zip() with no arguments now returns an empty list instead of raising a TypeError exception. +- obj.__contains__() now returns True/False instead of 1/0. SF patch + 820195. + Extension modules ----------------- diff --git a/Objects/typeobject.c b/Objects/typeobject.c index af255f156a..2708cdce86 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3569,14 +3569,16 @@ wrap_objobjproc(PyObject *self, PyObject *args, void *wrapped) { objobjproc func = (objobjproc)wrapped; int res; - PyObject *value; + PyObject *value, *ret; if (!PyArg_ParseTuple(args, "O", &value)) return NULL; res = (*func)(self, value); if (res == -1 && PyErr_Occurred()) return NULL; - return PyInt_FromLong((long)res); + ret = PyObject_IsTrue(PyInt_FromLong((long)res)) ? Py_True : Py_False; + Py_INCREF(ret); + return ret; } static PyObject *