getset_descr_set(): guard against deletion (indicated by a set call

with a NULL value), in a somewhat lame way: call the set() function
with one argument.  Should I add a 3rd function, 'del', instead?
This commit is contained in:
Guido van Rossum 2001-08-24 10:17:36 +00:00
parent 2c25239215
commit 845fc48bf7

View 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);