Issue #19512: Add a new _PyDict_DelItemId() function, similar to

PyDict_DelItemString() but using an identifier for the key
This commit is contained in:
Victor Stinner 2013-11-06 18:58:22 +01:00
parent 7a07e451a4
commit 5fd2e5ae8a
2 changed files with 10 additions and 0 deletions

View File

@ -109,6 +109,7 @@ PyAPI_FUNC(PyObject *) _PyDict_GetItemId(PyObject *dp, struct _Py_Identifier *ke
PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);
PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, struct _Py_Identifier *key, PyObject *item);
PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key);
PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, struct _Py_Identifier *key);
#ifndef Py_LIMITED_API
int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject *name, PyObject *value);

View File

@ -2735,6 +2735,15 @@ PyDict_SetItemString(PyObject *v, const char *key, PyObject *item)
return err;
}
int
_PyDict_DelItemId(PyObject *v, _Py_Identifier *key)
{
PyObject *kv = _PyUnicode_FromId(key); /* borrowed */
if (kv == NULL)
return -1;
return PyDict_DelItem(v, kv);
}
int
PyDict_DelItemString(PyObject *v, const char *key)
{