Skip to content

Commit 3a88ee7

Browse files
committed
Add C API function '_PyArg_NoKeywords'.
1 parent 87c6649 commit 3a88ee7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

graalpython/com.oracle.graal.python.cext/src/modsupport.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,3 +842,19 @@ int PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize
842842
#define PyArg_UnpackTuple _backup_PyArg_UnpackTuple
843843
#undef _backup_PyArg_UnpackTuple
844844
#endif
845+
846+
// taken from CPython 3.6.5 "Python/getargs.c"
847+
int _PyArg_NoKeywords(const char *funcname, PyObject *kw) {
848+
if (kw == NULL)
849+
return 1;
850+
if (!PyDict_CheckExact(kw)) {
851+
PyErr_BadInternalCall();
852+
return 0;
853+
}
854+
if (PyDict_Size(kw) == 0)
855+
return 1;
856+
857+
PyErr_Format(PyExc_TypeError, "%s does not take keyword arguments",
858+
funcname);
859+
return 0;
860+
}

0 commit comments

Comments
 (0)