]> granicus.if.org Git - python/commitdiff
Implement PyObject_DelItemString. Fixes #498915.
authorMartin v. Löwis <martin@v.loewis.de>
Sat, 5 Jan 2002 10:50:30 +0000 (10:50 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sat, 5 Jan 2002 10:50:30 +0000 (10:50 +0000)
Include/abstract.h
Objects/abstract.c

index 682c2f2e138646899407411979928bf7f0397ee1..226e5e8d0c0d861ff3f2d271e30b0747079afa33 100644 (file)
@@ -445,6 +445,14 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
         statement: o[key]=v.
        */
 
+     DL_IMPORT(int) PyObject_DelItemString(PyObject *o, char *key);
+
+       /*
+         Remove the mapping for object, key, from the object *o.
+         Returns -1 on failure.  This is equivalent to
+         the Python statement: del o[key].
+       */
+
      DL_IMPORT(int) PyObject_DelItem(PyObject *o, PyObject *key);
 
        /*
index 59314497bd41231f64a8e6e13138b02f6caf1b74..2acfd0865cecec9b75e025dfd04f2adc97c8d65a 100644 (file)
@@ -174,6 +174,24 @@ PyObject_DelItem(PyObject *o, PyObject *key)
        return -1;
 }
 
+int
+PyObject_DelItemString(PyObject *o, char *key)
+{
+       PyObject *okey;
+       int ret;
+
+       if (o == NULL || key == NULL) {
+               null_error();
+               return -1;
+       }
+       okey = PyString_FromString(key);
+       if (okey == NULL)
+               return -1;
+       ret = PyObject_DelItem(o, okey);
+       Py_DECREF(okey);
+       return ret;
+}
+
 int PyObject_AsCharBuffer(PyObject *obj,
                          const char **buffer,
                          int *buffer_len)