diff options
author | Guido van Rossum <guido@python.org> | 2001-08-24 10:13:31 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-08-24 10:13:31 (GMT) |
commit | 2c25239215964746e030d9f7e47232d4dca5746d (patch) | |
tree | fb3d2613cdbc3e84bfb29cddd5fca7b9fb529af0 | |
parent | 91c0d8a9223ed137b9824248bd5941c1d60feafd (diff) | |
download | cpython-2c25239215964746e030d9f7e47232d4dca5746d.zip cpython-2c25239215964746e030d9f7e47232d4dca5746d.tar.gz cpython-2c25239215964746e030d9f7e47232d4dca5746d.tar.bz2 |
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__.
-rw-r--r-- | Objects/typeobject.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index b64e10b..2017b1e 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2806,14 +2806,23 @@ slot_tp_descr_get(PyObject *self, PyObject *obj, PyObject *type) Py_INCREF(self); return self; } + if (obj == NULL) + obj = Py_None; + if (type == NULL) + type = Py_None; return PyObject_CallFunction(get, "OOO", self, obj, type); } static int slot_tp_descr_set(PyObject *self, PyObject *target, PyObject *value) { - PyObject *res = PyObject_CallMethod(self, "__set__", - "OO", target, value); + PyObject *res; + + if (value == NULL) + res = PyObject_CallMethod(self, "__del__", "O", target); + else + res = PyObject_CallMethod(self, "__set__", + "OO", target, value); if (res == NULL) return -1; Py_DECREF(res); |