]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1709: dynamic build with python 3.12 breaks v9.0.1709
authorZdenek Dohnal <zdohnal@redhat.com>
Sun, 13 Aug 2023 17:37:09 +0000 (19:37 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 13 Aug 2023 17:39:27 +0000 (19:39 +0200)
Problem: dynamic build with python 3.12 breaks
Solution: if_python3.c: Fix building dynamic Python3 interpreter

There are new extern global variables defined in python3 development
files, which types are within python3 library, so they break dynamic
python3 interpret Vim plugin.

Since the variables are used in macro `Py_SIZE` which is used in other
python3 headers, the dummy variables have to defined before including
Python.h.

closes: #12660

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Zdenek Dohnal <zdohnal@redhat.com>
src/if_python3.c
src/version.c

index 06c02ce67c097b7e6193a56b0f2dea11435fca3d..0a0d31e69811a2d4f32c88a52948c7546c797563 100644 (file)
@@ -68,6 +68,8 @@
 #endif
 
 #define PY_SSIZE_T_CLEAN
+#define PyLong_Type (*py3_PyLong_Type)
+#define PyBool_Type (*py3_PyBool_Type)
 
 #include <Python.h>
 
@@ -271,7 +273,6 @@ static HINSTANCE hinstPy3 = 0; // Instance of python.dll
 # define PyFloat_Type (*py3_PyFloat_Type)
 # define PyNumber_Check (*py3_PyNumber_Check)
 # define PyNumber_Long (*py3_PyNumber_Long)
-# define PyBool_Type (*py3_PyBool_Type)
 # define PyErr_NewException py3_PyErr_NewException
 # ifdef Py_DEBUG
 #  define _Py_NegativeRefcount py3__Py_NegativeRefcount
@@ -449,7 +450,10 @@ static PyTypeObject* py3_PyType_Type;
 static PyTypeObject* py3_PyStdPrinter_Type;
 static PyTypeObject* py3_PySlice_Type;
 static PyTypeObject* py3_PyFloat_Type;
-static PyTypeObject* py3_PyBool_Type;
+PyTypeObject* py3_PyBool_Type;
+# if PY_VERSION_HEX >= 0x030c00b0
+PyTypeObject* py3_PyLong_Type;
+# endif
 static int (*py3_PyNumber_Check)(PyObject *);
 static PyObject* (*py3_PyNumber_Long)(PyObject *);
 static PyObject* (*py3_PyErr_NewException)(char *name, PyObject *base, PyObject *dict);
@@ -625,6 +629,9 @@ static struct
     {"PySlice_Type", (PYTHON_PROC*)&py3_PySlice_Type},
     {"PyFloat_Type", (PYTHON_PROC*)&py3_PyFloat_Type},
     {"PyBool_Type", (PYTHON_PROC*)&py3_PyBool_Type},
+# if PY_VERSION_HEX >= 0x030c00b0
+    {"PyLong_Type", (PYTHON_PROC*)&py3_PyLong_Type},
+# endif
     {"PyNumber_Check", (PYTHON_PROC*)&py3_PyNumber_Check},
     {"PyNumber_Long", (PYTHON_PROC*)&py3_PyNumber_Long},
     {"PyErr_NewException", (PYTHON_PROC*)&py3_PyErr_NewException},
index d38e9b46f7ce8af7526ad61aa92d5fe3805f5aa2..311bb8c7333fbe436bb0cffdedf64509b8b2c4ef 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1709,
 /**/
     1708,
 /**/