From b630e14dc4f2c3ef7594f864eb29cb61578af8a0 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 7 Jan 2026 19:50:08 +0100 Subject: [PATCH] py_compat: Add vectorcall functions --- dtool/src/interrogatedb/py_compat.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dtool/src/interrogatedb/py_compat.h b/dtool/src/interrogatedb/py_compat.h index efbdc74d83..bfcea61e76 100644 --- a/dtool/src/interrogatedb/py_compat.h +++ b/dtool/src/interrogatedb/py_compat.h @@ -219,6 +219,14 @@ INLINE PyObject *_PyLong_Lshift(PyObject *a, size_t shiftby) { } #endif +#ifndef PY_VECTORCALL_ARGUMENTS_OFFSET +# define PY_VECTORCALL_ARGUMENTS_OFFSET (((size_t)1) << (8 * sizeof(size_t) - 1)) +#endif + +#if PY_VERSION_HEX < 0x030800B1 +# define PyVectorcall_NARGS(n) ((n) & ~PY_VECTORCALL_ARGUMENTS_OFFSET) +#endif + /* Python 3.9 */ #if PY_VERSION_HEX < 0x030900A4 && !defined(Py_IS_TYPE) @@ -229,6 +237,10 @@ INLINE PyObject *_PyLong_Lshift(PyObject *a, size_t shiftby) { # define PyCFunction_CheckExact(op) (Py_IS_TYPE(op, &PyCFunction_Type)) #endif +#if PY_VERSION_HEX < 0x030900A4 +# define PyObject_Vectorcall(callable, args, nargsf, kwnames) (_PyObject_Vectorcall((callable), (args), (nargsf), (kwnames))) +#endif + #if PY_VERSION_HEX < 0x03090000 INLINE PyObject *PyObject_CallNoArgs(PyObject *func) { #if PY_VERSION_HEX >= 0x03080000