mirror of
https://github.com/python/cpython.git
synced 2025-10-16 19:57:59 +00:00
bpo-37207: Add _PyArg_NoKwnames() helper function (GH-18980)
This commit is contained in:
parent
c98f87fc33
commit
87ec86c425
5 changed files with 24 additions and 5 deletions
|
@ -2787,6 +2787,7 @@ _PyArg_UnpackStack(PyObject *const *args, Py_ssize_t nargs, const char *name,
|
|||
|
||||
|
||||
#undef _PyArg_NoKeywords
|
||||
#undef _PyArg_NoKwnames
|
||||
#undef _PyArg_NoPositional
|
||||
|
||||
/* For type constructors that don't take keyword args
|
||||
|
@ -2813,7 +2814,6 @@ _PyArg_NoKeywords(const char *funcname, PyObject *kwargs)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_PyArg_NoPositional(const char *funcname, PyObject *args)
|
||||
{
|
||||
|
@ -2831,6 +2831,23 @@ _PyArg_NoPositional(const char *funcname, PyObject *args)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_PyArg_NoKwnames(const char *funcname, PyObject *kwnames)
|
||||
{
|
||||
if (kwnames == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
assert(PyTuple_CheckExact(kwnames));
|
||||
|
||||
if (PyTuple_GET_SIZE(kwnames) == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
PyErr_Format(PyExc_TypeError, "%s() takes no keyword arguments", funcname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
_PyArg_Fini(void)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue