summaryrefslogtreecommitdiffstats
path: root/Objects/odictobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-07-19 06:18:55 (GMT)
committerGitHub <noreply@github.com>2020-07-19 06:18:55 (GMT)
commit6bf3237379b17632db52cb39d181e8bac70173f3 (patch)
treef8e603563cc5cae091f48559c5559b1a3d51339a /Objects/odictobject.c
parentc53b310e5926266ce267c44a168165cacd786d6e (diff)
downloadcpython-6bf3237379b17632db52cb39d181e8bac70173f3.zip
cpython-6bf3237379b17632db52cb39d181e8bac70173f3.tar.gz
cpython-6bf3237379b17632db52cb39d181e8bac70173f3.tar.bz2
bpo-41333: Convert OrderedDict.pop() to Argument Clinic (GH-21534)
Diffstat (limited to 'Objects/odictobject.c')
-rw-r--r--Objects/odictobject.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/Objects/odictobject.c b/Objects/odictobject.c
index d5bf499..b4ac560 100644
--- a/Objects/odictobject.c
+++ b/Objects/odictobject.c
@@ -1045,30 +1045,28 @@ OrderedDict_setdefault_impl(PyODictObject *self, PyObject *key,
/* pop() */
-PyDoc_STRVAR(odict_pop__doc__,
-"od.pop(k[,d]) -> v, remove specified key and return the corresponding\n\
- value. If key is not found, d is returned if given, otherwise KeyError\n\
- is raised.\n\
-\n\
- ");
-
/* forward */
static PyObject * _odict_popkey(PyObject *, PyObject *, PyObject *);
/* Skips __missing__() calls. */
-static PyObject *
-odict_pop(PyObject *od, PyObject *args, PyObject *kwargs)
-{
- static char *kwlist[] = {"key", "default", 0};
- PyObject *key, *failobj = NULL;
+/*[clinic input]
+OrderedDict.pop
- /* borrowed */
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:pop", kwlist,
- &key, &failobj)) {
- return NULL;
- }
+ key: object
+ default: object = NULL
+
+od.pop(key[,default]) -> v, remove specified key and return the corresponding value.
+
+If the key is not found, return the default if given; otherwise,
+raise a KeyError.
+[clinic start generated code]*/
- return _odict_popkey(od, key, failobj);
+static PyObject *
+OrderedDict_pop_impl(PyODictObject *self, PyObject *key,
+ PyObject *default_value)
+/*[clinic end generated code: output=7a6447d104e7494b input=7efe36601007dff7]*/
+{
+ return _odict_popkey((PyObject *)self, key, default_value);
}
static PyObject *
@@ -1362,8 +1360,7 @@ static PyMethodDef odict_methods[] = {
{"__reduce__", (PyCFunction)odict_reduce, METH_NOARGS,
odict_reduce__doc__},
ORDEREDDICT_SETDEFAULT_METHODDEF
- {"pop", (PyCFunction)(void(*)(void))odict_pop,
- METH_VARARGS | METH_KEYWORDS, odict_pop__doc__},
+ ORDEREDDICT_POP_METHODDEF
ORDEREDDICT_POPITEM_METHODDEF
{"keys", odictkeys_new, METH_NOARGS,
odict_keys__doc__},