From: Martin v. Löwis Date: Sat, 5 Jan 2002 10:52:38 +0000 (+0000) Subject: Implement PyObject_DelItemString. Fixes #498915. X-Git-Tag: v2.2.1c1~249 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f63438ad81bc41a2bece664610c0e04608d19a0b;p=thirdparty%2FPython%2Fcpython.git Implement PyObject_DelItemString. Fixes #498915. --- diff --git a/Include/abstract.h b/Include/abstract.h index 682c2f2e1386..226e5e8d0c0d 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -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); /* diff --git a/Objects/abstract.c b/Objects/abstract.c index 59314497bd41..2acfd0865cec 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -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)