@@ -2987,23 +2987,37 @@ dict_clear(PyDictObject *mp, PyObject *Py_UNUSED(ignored))
2987
2987
Py_RETURN_NONE ;
2988
2988
}
2989
2989
2990
- /*[clinic input]
2991
- dict.pop
2992
-
2993
- key: object
2994
- default: object = NULL
2995
- /
2990
+ /*
2991
+ We don't use Argument Clinic for dict.pop because it doesn't support
2992
+ custom signature for now.
2993
+ */
2994
+ PyDoc_STRVAR (dict_pop__doc__ ,
2995
+ "D.pop(k[,d]) -> v, remove specified key and return the corresponding value.\n\
2996
+ If key is not found, d is returned if given, otherwise KeyError is raised" );
2996
2997
2997
- Remove specified key and return the corresponding value.
2998
-
2999
- If key is not found, default is returned if given, otherwise KeyError is raised
3000
- [clinic start generated code]*/
2998
+ #define DICT_POP_METHODDEF \
2999
+ {"pop", (PyCFunction)(void(*)(void))dict_pop, METH_FASTCALL, dict_pop__doc__},
3001
3000
3002
3001
static PyObject *
3003
- dict_pop_impl (PyDictObject * self , PyObject * key , PyObject * default_value )
3004
- /*[clinic end generated code: output=3abb47b89f24c21c input=016f6a000e4e633b]*/
3002
+ dict_pop (PyDictObject * self , PyObject * const * args , Py_ssize_t nargs )
3005
3003
{
3006
- return _PyDict_Pop ((PyObject * )self , key , default_value );
3004
+ PyObject * return_value = NULL ;
3005
+ PyObject * key ;
3006
+ PyObject * default_value = NULL ;
3007
+
3008
+ if (!_PyArg_CheckPositional ("pop" , nargs , 1 , 2 )) {
3009
+ goto exit ;
3010
+ }
3011
+ key = args [0 ];
3012
+ if (nargs < 2 ) {
3013
+ goto skip_optional ;
3014
+ }
3015
+ default_value = args [1 ];
3016
+ skip_optional :
3017
+ return_value = _PyDict_Pop ((PyObject * )self , key , default_value );
3018
+
3019
+ exit :
3020
+ return return_value ;
3007
3021
}
3008
3022
3009
3023
/*[clinic input]
0 commit comments