Browse Source

py_panda: backport some py_compat.h definitions

rdb 5 years ago
parent
commit
a7042091be
1 changed files with 22 additions and 0 deletions
  1. 22 0
      dtool/src/interrogatedb/py_compat.h

+ 22 - 0
dtool/src/interrogatedb/py_compat.h

@@ -208,6 +208,28 @@ INLINE PyObject *_PyLong_Lshift(PyObject *a, size_t shiftby) {
 }
 }
 #endif
 #endif
 
 
+#if PY_VERSION_HEX < 0x03090000
+INLINE EXPCL_PYPANDA PyObject *PyObject_CallNoArgs(PyObject *func) {
+  return _PyObject_CallNoArg(func);
+}
+
+INLINE PyObject *PyObject_CallOneArg(PyObject *callable, PyObject *arg) {
+#if PY_VERSION_HEX >= 0x03060000
+  return _PyObject_FastCall(callable, &arg, 1);
+#else
+  return PyObject_CallFunctionObjArgs(callable, arg, nullptr);
+#endif
+}
+
+INLINE PyObject *PyObject_CallMethodNoArgs(PyObject *obj, PyObject *name) {
+  return PyObject_CallMethodObjArgs(obj, name, nullptr);
+}
+
+INLINE PyObject *PyObject_CallMethodOneArg(PyObject *obj, PyObject *name, PyObject *arg) {
+  return PyObject_CallMethodObjArgs(obj, name, arg, nullptr);
+}
+#endif
+
 /* Other Python implementations */
 /* Other Python implementations */
 
 
 // _PyErr_OCCURRED is an undocumented macro version of PyErr_Occurred.
 // _PyErr_OCCURRED is an undocumented macro version of PyErr_Occurred.