slot_tp_descr_get(): guard against NULL obj or type (bug reported by
Thomas Hellor on python-dev). slot_tp_descr_set(): if value is NULL, call __del__ instead of __set__.
This commit is contained in:
parent
91c0d8a922
commit
2c25239215
|
@ -2806,14 +2806,23 @@ slot_tp_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
||||||
Py_INCREF(self);
|
Py_INCREF(self);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
if (obj == NULL)
|
||||||
|
obj = Py_None;
|
||||||
|
if (type == NULL)
|
||||||
|
type = Py_None;
|
||||||
return PyObject_CallFunction(get, "OOO", self, obj, type);
|
return PyObject_CallFunction(get, "OOO", self, obj, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
slot_tp_descr_set(PyObject *self, PyObject *target, PyObject *value)
|
slot_tp_descr_set(PyObject *self, PyObject *target, PyObject *value)
|
||||||
{
|
{
|
||||||
PyObject *res = PyObject_CallMethod(self, "__set__",
|
PyObject *res;
|
||||||
"OO", target, value);
|
|
||||||
|
if (value == NULL)
|
||||||
|
res = PyObject_CallMethod(self, "__del__", "O", target);
|
||||||
|
else
|
||||||
|
res = PyObject_CallMethod(self, "__set__",
|
||||||
|
"OO", target, value);
|
||||||
if (res == NULL)
|
if (res == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
Py_DECREF(res);
|
Py_DECREF(res);
|
||||||
|
|
Loading…
Reference in New Issue