74af866
From 939e0db21a5145d6a84eb8922ba3dc3a14fb4572 Mon Sep 17 00:00:00 2001
74af866
From: Zdenek Dohnal <zdohnal@redhat.com>
74af866
Date: Wed, 12 Jul 2023 13:13:38 +0200
74af866
Subject: [PATCH] if_python3.c: Fix building dynamic Python3 interpreter
74af866
74af866
There are new extern global variables defined in python3 development
74af866
files, which types are within python3 library, so they break dynamic
74af866
python3 interpret Vim plugin.
74af866
74af866
Since the variables are used in macro `Py_SIZE` which is used in other
74af866
python3 headers, the dummy variables have to defined before including
74af866
Python.h.
74af866
---
74af866
 src/if_python3.c | 11 +++++++++--
74af866
 1 file changed, 9 insertions(+), 2 deletions(-)
74af866
74af866
diff --git a/src/if_python3.c b/src/if_python3.c
74af866
index 240b88fac..f6704a31e 100644
74af866
--- a/src/if_python3.c
74af866
+++ b/src/if_python3.c
74af866
@@ -68,6 +68,8 @@
74af866
 #endif
74af866
 
74af866
 #define PY_SSIZE_T_CLEAN
74af866
+#define PyLong_Type (*py3_PyLong_Type)
74af866
+#define PyBool_Type (*py3_PyBool_Type)
74af866
 
74af866
 #include <Python.h>
74af866
 
74af866
@@ -270,7 +272,6 @@ static HINSTANCE hinstPy3 = 0; // Instance of python.dll
74af866
 # define PyFloat_Type (*py3_PyFloat_Type)
74af866
 # define PyNumber_Check (*py3_PyNumber_Check)
74af866
 # define PyNumber_Long (*py3_PyNumber_Long)
74af866
-# define PyBool_Type (*py3_PyBool_Type)
74af866
 # define PyErr_NewException py3_PyErr_NewException
74af866
 # ifdef Py_DEBUG
74af866
 #  define _Py_NegativeRefcount py3__Py_NegativeRefcount
74af866
@@ -448,7 +449,10 @@ static PyTypeObject* py3_PyType_Type;
74af866
 static PyTypeObject* py3_PyStdPrinter_Type;
74af866
 static PyTypeObject* py3_PySlice_Type;
74af866
 static PyTypeObject* py3_PyFloat_Type;
74af866
-static PyTypeObject* py3_PyBool_Type;
74af866
+PyTypeObject* py3_PyBool_Type;
74af866
+# if PY_VERSION_HEX >= 0x030c00b0
74af866
+PyTypeObject* py3_PyLong_Type;
74af866
+# endif
74af866
 static int (*py3_PyNumber_Check)(PyObject *);
74af866
 static PyObject* (*py3_PyNumber_Long)(PyObject *);
74af866
 static PyObject* (*py3_PyErr_NewException)(char *name, PyObject *base, PyObject *dict);
74af866
@@ -624,6 +628,9 @@ static struct
74af866
     {"PySlice_Type", (PYTHON_PROC*)&py3_PySlice_Type},
74af866
     {"PyFloat_Type", (PYTHON_PROC*)&py3_PyFloat_Type},
74af866
     {"PyBool_Type", (PYTHON_PROC*)&py3_PyBool_Type},
74af866
+# if PY_VERSION_HEX >= 0x030c00b0
74af866
+    {"PyLong_Type", (PYTHON_PROC*)&py3_PyLong_Type},
74af866
+# endif
74af866
     {"PyNumber_Check", (PYTHON_PROC*)&py3_PyNumber_Check},
74af866
     {"PyNumber_Long", (PYTHON_PROC*)&py3_PyNumber_Long},
74af866
     {"PyErr_NewException", (PYTHON_PROC*)&py3_PyErr_NewException},
74af866
-- 
74af866
2.41.0
74af866