|
@@ -50,6 +50,11 @@
|
|
|
#define PY_EXTERN extern
|
|
|
#endif
|
|
|
|
|
|
+typedef struct python_version {
|
|
|
+ int major;
|
|
|
+ int minor;
|
|
|
+} python_version_t;
|
|
|
+
|
|
|
PY_EXTERN int (*Import_PyType_Ready)(PyTypeObject *);
|
|
|
PY_EXTERN PyObject *(*Import_PyObject_GenericGetAttr)(PyObject *, PyObject *);
|
|
|
PY_EXTERN int (*Import_PyObject_IsTrue)(PyObject *);
|
|
@@ -99,10 +104,8 @@ PY_EXTERN int (*Import_PyDict_SetItemString)(PyObject *dp, const char *key,
|
|
|
PyObject *item);
|
|
|
PY_EXTERN PyObject *(*Import_PyCFunction_NewEx)(PyMethodDef *, PyObject *,
|
|
|
PyObject *);
|
|
|
-#if PY_VERSION_HEX > 0x030900b0
|
|
|
PY_EXTERN PyObject *(*Import_PyCMethod_New)(PyMethodDef *, PyObject *,
|
|
|
PyObject *, PyTypeObject *);
|
|
|
-#endif
|
|
|
PY_EXTERN PyObject *(*Import_PyModule_GetDict)(PyObject *);
|
|
|
PY_EXTERN PyObject *(*Import_PyModule_GetNameObject)(PyObject *);
|
|
|
PY_EXTERN int (*Import_PyModule_AddObject)(PyObject *, const char *,
|
|
@@ -139,23 +142,17 @@ PY_EXTERN PyObject *(*Import_PyLong_FromUnsignedLongLong)(unsigned long long);
|
|
|
PY_EXTERN int (*Import_PyArg_VaParse)(PyObject *, const char *, va_list);
|
|
|
PY_EXTERN PyObject(*Import__Py_NoneStruct);
|
|
|
PY_EXTERN PyObject *(*Import_PyTuple_New)(Py_ssize_t size);
|
|
|
-#if PY_VERSION_HEX >= 0x030900b0
|
|
|
PY_EXTERN int (*Import_PyType_GetFlags)(PyTypeObject *o);
|
|
|
-#endif
|
|
|
#if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030900b0
|
|
|
PY_EXTERN void (*Import__Py_Dealloc)(PyObject *obj);
|
|
|
#endif
|
|
|
|
|
|
-extern bool import_python(const char *python_path);
|
|
|
+extern bool import_python(const char *python_path,
|
|
|
+ python_version_t *python_version);
|
|
|
|
|
|
#ifndef NO_REDEFS
|
|
|
#define PyType_Ready Import_PyType_Ready
|
|
|
-#if PY_VERSION_HEX >= 0x030900b0
|
|
|
#define PyType_GetFlags Import_PyType_GetFlags
|
|
|
-#endif
|
|
|
-#if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030900b0
|
|
|
-#define _Py_Dealloc Import__Py_Dealloc
|
|
|
-#endif
|
|
|
#define PyObject_GenericGetAttr Import_PyObject_GenericGetAttr
|
|
|
#define PyObject_IsTrue Import_PyObject_IsTrue
|
|
|
#define Py_DecRef Import_Py_DecRef
|
|
@@ -231,6 +228,9 @@ extern bool import_python(const char *python_path);
|
|
|
#define PyArg_VaParse Import_PyArg_VaParse
|
|
|
#define _Py_NoneStruct (*Import__Py_NoneStruct)
|
|
|
#define PyTuple_New Import_PyTuple_New
|
|
|
+#if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030900b0
|
|
|
+#define _Py_Dealloc Import__Py_Dealloc
|
|
|
+#endif
|
|
|
#if PY_VERSION_HEX >= 0x030800f0
|
|
|
static inline void Import__Py_DECREF(const char *filename, int lineno,
|
|
|
PyObject *op)
|
|
@@ -262,7 +262,6 @@ static inline void Import__Py_XDECREF(PyObject *op)
|
|
|
#undef Py_XDECREF
|
|
|
#define Py_XDECREF(op) Import__Py_XDECREF(_PyObject_CAST(op))
|
|
|
#endif // PY_VERSION_HEX >= 0x030800f0
|
|
|
-
|
|
|
#if PY_VERSION_HEX >= 0x030900b0
|
|
|
static inline int Import_PyType_HasFeature(PyTypeObject *type,
|
|
|
unsigned long feature)
|