8000 Work around _PyArg_NoKeywords moving to a private header in CPython 3.13 · sqlalchemy/sqlalchemy@8a5888b · GitHub
[go: up one dir, main page]

Skip to content

Commit 8a5888b

Browse files
Work around _PyArg_NoKeywords moving to a private header in CPython 3.13
See: python/cpython#110964 Fixes: #11499
1 parent b13cdd1 commit 8a5888b

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

lib/sqlalchemy/cextension/resultproxy.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,14 +821,37 @@ typedef struct {
821821

822822
static PyTypeObject tuplegetter_type;
823823

824+
static int
825+
PyArg_NoKeywords(const char *funcname, PyObject *kwargs)
826+
{
827+
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 13
828+
/* Based on the one in CPython, removed from the public headers in 3.13
829+
* (https://github.com/python/cpython/issues/110964)
830+
*/
831+
if (kwargs == NULL)
832+
return 1;
833+
if (!PyDict_CheckExact(kwargs)) {
834+
PyErr_BadInternalCall();
835+
return 0;
836+
}
837+
if (PyDict_GET_SIZE(kwargs) == 0)
838+
return 1;
839+
840+
PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", funcname);
841+
return 0;
842+
#else
843+
return _PyArg_NoKeywords(funcname, kwargs);
844+
#endif
845+
}
846+
824847
static PyObject *
825848
tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
826849
{
827850
tuplegetterobject *tg;
828851
PyObject *item;
829852
Py_ssize_t nitems;
830853

831-
if (!_PyArg_NoKeywords("tuplegetter", kwds))
854+
if (!PyArg_NoKeywords("tuplegetter", kwds))
832855
return NULL;
833856

834857
nitems = PyTuple_GET_SIZE(args);

0 commit comments

Comments
 (0)
0