mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Stop using Argument Clinic for dict_pop (GH-13935)
This commit is contained in:
parent
518dc94e42
commit
d4c664736e
2 changed files with 28 additions and 50 deletions
38
Objects/clinic/dictobject.c.h
generated
38
Objects/clinic/dictobject.c.h
generated
|
@ -116,42 +116,6 @@ exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(dict_pop__doc__,
|
|
||||||
"pop($self, key, default=None, /)\n"
|
|
||||||
"--\n"
|
|
||||||
"\n"
|
|
||||||
"Remove specified key and return the corresponding value.\n"
|
|
||||||
"\n"
|
|
||||||
"If key is not found, default is returned if given, otherwise KeyError is raised");
|
|
||||||
|
|
||||||
#define DICT_POP_METHODDEF \
|
|
||||||
{"pop", (PyCFunction)(void(*)(void))dict_pop, METH_FASTCALL, dict_pop__doc__},
|
|
||||||
|
|
||||||
static PyObject *
|
|
||||||
dict_pop_impl(PyDictObject *self, PyObject *key, PyObject *default_value);
|
|
||||||
|
|
||||||
static PyObject *
|
|
||||||
dict_pop(PyDictObject *self, PyObject *const *args, Py_ssize_t nargs)
|
|
||||||
{
|
|
||||||
PyObject *return_value = NULL;
|
|
||||||
PyObject *key;
|
|
||||||
PyObject *default_value = NULL;
|
|
||||||
|
|
||||||
if (!_PyArg_CheckPositional("pop", nargs, 1, 2)) {
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
key = args[0];
|
|
||||||
if (nargs < 2) {
|
|
||||||
goto skip_optional;
|
|
||||||
}
|
|
||||||
default_value = args[1];
|
|
||||||
skip_optional:
|
|
||||||
return_value = dict_pop_impl(self, key, default_value);
|
|
||||||
|
|
||||||
exit:
|
|
||||||
return return_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyDoc_STRVAR(dict_popitem__doc__,
|
PyDoc_STRVAR(dict_popitem__doc__,
|
||||||
"popitem($self, /)\n"
|
"popitem($self, /)\n"
|
||||||
"--\n"
|
"--\n"
|
||||||
|
@ -190,4 +154,4 @@ dict___reversed__(PyDictObject *self, PyObject *Py_UNUSED(ignored))
|
||||||
{
|
{
|
||||||
return dict___reversed___impl(self);
|
return dict___reversed___impl(self);
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=0fd5cafc61a51d3c input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=676532dcc941d399 input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -2987,23 +2987,37 @@ dict_clear(PyDictObject *mp, PyObject *Py_UNUSED(ignored))
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*[clinic input]
|
/*
|
||||||
dict.pop
|
We don't use Argument Clinic for dict.pop because it doesn't support
|
||||||
|
custom signature for now.
|
||||||
|
*/
|
||||||
|
PyDoc_STRVAR(dict_pop__doc__,
|
||||||
|
"D.pop(k[,d]) -> v, remove specified key and return the corresponding value.\n\
|
||||||
|
If key is not found, d is returned if given, otherwise KeyError is raised");
|
||||||
|
|
||||||
key: object
|
#define DICT_POP_METHODDEF \
|
||||||
default: object = NULL
|
{"pop", (PyCFunction)(void(*)(void))dict_pop, METH_FASTCALL, dict_pop__doc__},
|
||||||
/
|
|
||||||
|
|
||||||
Remove specified key and return the corresponding value.
|
|
||||||
|
|
||||||
If key is not found, default is returned if given, otherwise KeyError is raised
|
|
||||||
[clinic start generated code]*/
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dict_pop_impl(PyDictObject *self, PyObject *key, PyObject *default_value)
|
dict_pop(PyDictObject *self, PyObject *const *args, Py_ssize_t nargs)
|
||||||
/*[clinic end generated code: output=3abb47b89f24c21c input=016f6a000e4e633b]*/
|
|
||||||
{
|
{
|
||||||
return _PyDict_Pop((PyObject*)self, key, default_value);
|
PyObject *return_value = NULL;
|
||||||
|
PyObject *key;
|
||||||
|
PyObject *default_value = NULL;
|
||||||
|
|
||||||
|
if (!_PyArg_CheckPositional("pop", nargs, 1, 2)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
key = args[0];
|
||||||
|
if (nargs < 2) {
|
||||||
|
goto skip_optional;
|
||||||
|
}
|
||||||
|
default_value = args[1];
|
||||||
|
skip_optional:
|
||||||
|
return_value = _PyDict_Pop((PyObject*)self, key, default_value);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*[clinic input]
|
/*[clinic input]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue