]> granicus.if.org Git - python/commitdiff
Fix SF #442791 (revisited): No __delitem__ wrapper was defined.
authorGuido van Rossum <guido@python.org>
Thu, 2 Aug 2001 15:31:58 +0000 (15:31 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 2 Aug 2001 15:31:58 +0000 (15:31 +0000)
Objects/typeobject.c

index 429680d148e212ea4490a01d43581371c3e51e4b..9b7243b1e672854ed3fe7c019df31fd3ff3df698 100644 (file)
@@ -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}
 };