diff options
author | Guido van Rossum <guido@python.org> | 2001-08-02 15:31:58 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-08-02 15:31:58 (GMT) |
commit | 2b8d7bdd771b39a7bbddb53f911624c2ef5b0824 (patch) | |
tree | 1268872e4f33a9349b13f1f30ad356497c49c9b4 | |
parent | 388f37e6f6ca4c80ba220062aae1db70a8f9a535 (diff) | |
download | cpython-2b8d7bdd771b39a7bbddb53f911624c2ef5b0824.zip cpython-2b8d7bdd771b39a7bbddb53f911624c2ef5b0824.tar.gz cpython-2b8d7bdd771b39a7bbddb53f911624c2ef5b0824.tar.bz2 |
Fix SF #442791 (revisited): No __delitem__ wrapper was defined.
-rw-r--r-- | Objects/typeobject.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 429680d..9b7243b 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1504,9 +1504,26 @@ wrap_intobjargproc(PyObject *self, PyObject *args, void *wrapped) return Py_None; } +static PyObject * +wrap_delitem_int(PyObject *self, PyObject *args, void *wrapped) +{ + intobjargproc func = (intobjargproc)wrapped; + int i, res; + + if (!PyArg_ParseTuple(args, "i", &i)) + return NULL; + res = (*func)(self, i, NULL); + if (res == -1 && PyErr_Occurred()) + return NULL; + Py_INCREF(Py_None); + return Py_None; +} + static struct wrapperbase tab_setitem_int[] = { {"__setitem__", (wrapperfunc)wrap_intobjargproc, "x.__setitem__(i, y) <==> x[i]=y"}, + {"__delitem__", (wrapperfunc)wrap_delitem_int, + "x.__delitem__(y) <==> del x[y]"}, {0} }; @@ -1570,9 +1587,27 @@ wrap_objobjargproc(PyObject *self, PyObject *args, void *wrapped) return Py_None; } +static PyObject * +wrap_delitem(PyObject *self, PyObject *args, void *wrapped) +{ + objobjargproc func = (objobjargproc)wrapped; + int res; + PyObject *key; + + if (!PyArg_ParseTuple(args, "O", &key)) + return NULL; + res = (*func)(self, key, NULL); + if (res == -1 && PyErr_Occurred()) + return NULL; + Py_INCREF(Py_None); + return Py_None; +} + static struct wrapperbase tab_setitem[] = { {"__setitem__", (wrapperfunc)wrap_objobjargproc, "x.__setitem__(y, z) <==> x[y]=z"}, + {"__delitem__", (wrapperfunc)wrap_delitem, + "x.__delitem__(y) <==> del x[y]"}, {0} }; |