Skip to content

Commit 7f36fde

Browse files
committed
Inline _PyArg_NoKeywords from Python 3.13 in case it is missing
Python 3.13 made this private: python/cpython#110966 Fixes pygame#4099
1 parent 00f0c57 commit 7f36fde

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src_c/math.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4413,6 +4413,34 @@ com_descr_get(PyObject *self, PyObject *obj, PyObject *type)
44134413
return PyMethod_New(com->obj_callable, obj);
44144414
}
44154415

4416+
#ifndef _PyArg_NoKeywords
4417+
/* For type constructors that don't take keyword args
4418+
*
4419+
* Sets a TypeError and returns 0 if the args/kwargs is
4420+
* not empty, returns 1 otherwise
4421+
*
4422+
* From Python 3.13.0b2, Python/getargs.c
4423+
*/
4424+
int
4425+
_PyArg_NoKeywords(const char *funcname, PyObject *kwargs)
4426+
{
4427+
if (kwargs == NULL) {
4428+
return 1;
4429+
}
4430+
if (!PyDict_CheckExact(kwargs)) {
4431+
PyErr_BadInternalCall();
4432+
return 0;
4433+
}
4434+
if (PyDict_GET_SIZE(kwargs) == 0) {
4435+
return 1;
4436+
}
4437+
4438+
PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
4439+
funcname);
4440+
return 0;
4441+
}
4442+
#endif
4443+
44164444
static int
44174445
com_init(PyObject *self, PyObject *args, PyObject *kwds)
44184446
{

0 commit comments

Comments
 (0)