summaryrefslogtreecommitdiffstats
path: root/Python/getargs.c
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2020-03-16 14:06:20 (GMT)
committerGitHub <noreply@github.com>2020-03-16 14:06:20 (GMT)
commit87ec86c425a5cd3ad41b831b54c0ce1a0c363f4b (patch)
tree8c51144ad1a0b7c88c29e63f1063537096c6c15b /Python/getargs.c
parentc98f87fc330eb40fbcff627dfc50958785a44f35 (diff)
downloadcpython-87ec86c425a5cd3ad41b831b54c0ce1a0c363f4b.zip
cpython-87ec86c425a5cd3ad41b831b54c0ce1a0c363f4b.tar.gz
cpython-87ec86c425a5cd3ad41b831b54c0ce1a0c363f4b.tar.bz2
bpo-37207: Add _PyArg_NoKwnames() helper function (GH-18980)
Diffstat (limited to 'Python/getargs.c')
-rw-r--r--Python/getargs.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index d644aea..062f814 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -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)
{