]> granicus.if.org Git - python/commitdiff
SF patch #820195 by Wojtek Walczak (gminick at users.sourceforge.net):
authorGuido van Rossum <guido@python.org>
Wed, 8 Oct 2003 21:08:29 +0000 (21:08 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 8 Oct 2003 21:08:29 +0000 (21:08 +0000)
make obj.__contains__() returns True/False instead of 1/0.

Misc/ACKS
Misc/NEWS
Objects/typeobject.c

index 74bfbfa7028ee1a95299a9493aaf22f72c142703..67c1cecf20d08e57b96f36f9a1da9c5cf2e40083 100644 (file)
--- 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
index 5a8379e83d303a779572cd20224129d326dd05eb..8662f10e178ee1b15d79ed5ef928871bfe7d8a78 100644 (file)
--- 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
 -----------------
 
index af255f156aaa3d6a4c3a75aa2f7ff2a93467d37a..2708cdce867c482f03b580384aa1d230ec04ca39 100644 (file)
@@ -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 *