diff --git a/dtool/src/interrogatedb/py_compat.cxx b/dtool/src/interrogatedb/py_compat.cxx index 575a7f8241..722bc8300b 100644 --- a/dtool/src/interrogatedb/py_compat.cxx +++ b/dtool/src/interrogatedb/py_compat.cxx @@ -43,22 +43,4 @@ size_t PyLongOrInt_AsSize_t(PyObject *vv) { } #endif -#if PY_VERSION_HEX < 0x03090000 -/** - * Most efficient way to call a function without any arguments. - */ -PyObject *PyObject_CallNoArgs(PyObject *func) { -#if PY_VERSION_HEX >= 0x03080000 - return _PyObject_Vectorcall(func, nullptr, 0, nullptr); -#elif PY_VERSION_HEX >= 0x03070000 - return _PyObject_FastCallDict(func, nullptr, 0, nullptr); -#elif PY_VERSION_HEX >= 0x03060000 - return _PyObject_FastCall(func, nullptr, 0); -#else - static PyObject *empty_tuple = PyTuple_New(0); - return PyObject_Call(func, empty_tuple, nullptr); -#endif -} -#endif - #endif // HAVE_PYTHON diff --git a/dtool/src/interrogatedb/py_compat.h b/dtool/src/interrogatedb/py_compat.h index f294651acc..8cdcb107cf 100644 --- a/dtool/src/interrogatedb/py_compat.h +++ b/dtool/src/interrogatedb/py_compat.h @@ -212,7 +212,17 @@ INLINE PyObject *_PyLong_Lshift(PyObject *a, size_t shiftby) { /* Python 3.9 */ #if PY_VERSION_HEX < 0x03090000 -EXPCL_PYPANDA PyObject *PyObject_CallNoArgs(PyObject *func); +INLINE PyObject *PyObject_CallNoArgs(PyObject *func) { +#if PY_VERSION_HEX >= 0x03080000 + return _PyObject_Vectorcall(func, nullptr, 0, nullptr); +#elif PY_VERSION_HEX >= 0x03070000 + return _PyObject_FastCallDict(func, nullptr, 0, nullptr); +#elif PY_VERSION_HEX >= 0x03060000 + return _PyObject_FastCall(func, nullptr, 0); +#else + return PyObject_CallObject(func, nullptr); +#endif +} INLINE PyObject *PyObject_CallOneArg(PyObject *callable, PyObject *arg) { #if PY_VERSION_HEX >= 0x03060000