getset_descr_set(): guard against deletion (indicated by a set call
authorGuido van Rossum <guido@python.org>
Fri, 24 Aug 2001 10:17:36 +0000 (10:17 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 24 Aug 2001 10:17:36 +0000 (10:17 +0000)
with a NULL value), in a somewhat lame way: call the set() function
with one argument.  Should I add a 3rd function, 'del', instead?

Objects/descrobject.c

index a9ee2a4a1278d7b3f1775d8643824fd9b4936caf..c29dd833dfa757b4070e96b4fd7c5c735469ffcc 100644 (file)
@@ -906,7 +906,10 @@ getset_descr_set(PyObject *self, PyObject *obj, PyObject *value)
                PyErr_SetString(PyExc_AttributeError, "unsettable attribute");
                return -1;
        }
-       res = PyObject_CallFunction(gs->set, "(OO)", obj, value);
+       if (value == NULL)
+               res = PyObject_CallFunction(gs->set, "(O)", obj);
+       else
+               res = PyObject_CallFunction(gs->set, "(OO)", obj, value);
        if (res == NULL)
                return -1;
        Py_DECREF(res);