Skip to content

Commit

Permalink
Implement PyObject_DelItemString. Fixes #498915.
Browse files Browse the repository at this point in the history
  • Loading branch information
loewis committed Jan 5, 2002
1 parent 7731ed4 commit b0d71d0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Include/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/*
Expand Down
18 changes: 18 additions & 0 deletions Objects/abstract.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b0d71d0

Please sign in to comment.