summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Takata <kentkt@csc.jp>2024-08-10 09:44:20 +0200
committerChristian Brabandt <cb@256bit.org>2024-08-10 09:44:20 +0200
commit9abd7158d7d10b2b6a6b786c5ef0d428f690e37d (patch)
tree0a517d522ac273f3523a2435cb7b14f2dc9a9ef8
parent181fda18e98620144a0e82a5b5a80dc47448af20 (diff)
patch 9.1.0668: build-error with python3.12 and stable ABIv9.1.0668
Problem: build-error with python3.12 and stable ABI (zdohnal) Solution: Add type casts, define Py_INCREF for Python3.12 and higher (Ken Takata) fixes: #15460 Signed-off-by: Ken Takata <kentkt@csc.jp> Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r--src/if_py_both.h14
-rw-r--r--src/if_python3.c44
-rw-r--r--src/version.c2
3 files changed, 52 insertions, 8 deletions
diff --git a/src/if_py_both.h b/src/if_py_both.h
index d09b14c756..3643f8be27 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -3083,7 +3083,7 @@ ListConcatInPlace(ListObject *self, PyObject *obj)
}
Py_DECREF(lookup_dict);
- Py_INCREF(self);
+ Py_INCREF((PyObject *)self);
return (PyObject *)(self);
}
@@ -4012,7 +4012,7 @@ TabPageNew(tabpage_T *tab)
if (TAB_PYTHON_REF(tab))
{
self = TAB_PYTHON_REF(tab);
- Py_INCREF(self);
+ Py_INCREF((PyObject *)self);
}
else
{
@@ -4206,7 +4206,7 @@ WindowNew(win_T *win, tabpage_T *tab)
if (WIN_PYTHON_REF(win))
{
self = WIN_PYTHON_REF(win);
- Py_INCREF(self);
+ Py_INCREF((PyObject *)self);
}
else
{
@@ -4334,7 +4334,7 @@ WindowAttr(WindowObject *self, char *name)
}
else if (strcmp(name, "tabpage") == 0)
{
- Py_INCREF(self->tabObject);
+ Py_INCREF((PyObject *)self->tabObject);
return (PyObject *)(self->tabObject);
}
else if (strcmp(name, "__members__") == 0)
@@ -4488,7 +4488,7 @@ WinListNew(TabPageObject *tabObject)
self = PyObject_NEW(WinListObject, WinListTypePtr);
self->tabObject = tabObject;
- Py_INCREF(tabObject);
+ Py_INCREF((PyObject *)tabObject);
return (PyObject *)(self);
}
@@ -5383,7 +5383,7 @@ RangeNew(buf_T *buf, PyInt start, PyInt end)
Py_DECREF(self);
return NULL;
}
- Py_INCREF(bufr);
+ Py_INCREF((PyObject *)bufr);
self->buf = bufr;
self->start = start;
@@ -5512,7 +5512,7 @@ BufferNew(buf_T *buf)
if (BUF_PYTHON_REF(buf) != NULL)
{
self = BUF_PYTHON_REF(buf);
- Py_INCREF(self);
+ Py_INCREF((PyObject *)self);
}
else
{
diff --git a/src/if_python3.c b/src/if_python3.c
index 96c9497712..ac817bdce4 100644
--- a/src/if_python3.c
+++ b/src/if_python3.c
@@ -219,6 +219,17 @@ static HINSTANCE hinstPy3 = 0; // Instance of python.dll
# define PyObject_GetItem py3_PyObject_GetItem
# define PyObject_IsTrue py3_PyObject_IsTrue
# define PyModule_GetDict py3_PyModule_GetDict
+# if defined(USE_LIMITED_API) \
+ && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))
+# undef Py_INCREF
+# if Py_LIMITED_API+0 >= 0x030a00A7
+# define _Py_IncRef py3__Py_IncRef
+# define Py_INCREF _Py_IncRef
+# else
+# define Py_IncRef py3_Py_IncRef
+# define Py_INCREF Py_IncRef
+# endif
+# endif
# ifdef USE_LIMITED_API
# define Py_CompileString py3_Py_CompileString
# define PyEval_EvalCode py3_PyEval_EvalCode
@@ -391,6 +402,15 @@ static void (*py3_Py_Finalize)(void);
static void (*py3_PyErr_SetString)(PyObject *, const char *);
static void (*py3_PyErr_SetObject)(PyObject *, PyObject *);
static int (*py3_PyErr_ExceptionMatches)(PyObject *);
+# if defined(USE_LIMITED_API) \
+ && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))
+# if Py_LIMITED_API+0 >= 0x030a00A7
+# define _Py_IncRef py3__Py_IncRef
+static void (*py3__Py_IncRef)(PyObject *);
+# else
+static void (*py3_Py_IncRef)(PyObject *);
+# endif
+# endif
# ifdef USE_LIMITED_API
static PyObject* (*py3_Py_CompileString)(const char *, const char *, int);
static PyObject* (*py3_PyEval_EvalCode)(PyObject *co, PyObject *globals, PyObject *locals);
@@ -598,6 +618,14 @@ static struct
{"PyErr_SetString", (PYTHON_PROC*)&py3_PyErr_SetString},
{"PyErr_SetObject", (PYTHON_PROC*)&py3_PyErr_SetObject},
{"PyErr_ExceptionMatches", (PYTHON_PROC*)&py3_PyErr_ExceptionMatches},
+# if defined(USE_LIMITED_API) \
+ && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))
+# if Py_LIMITED_API+0 >= 0x030a00A7
+ {"_Py_IncRef", (PYTHON_PROC*)&py3__Py_IncRef},
+# else
+ {"Py_IncRef", (PYTHON_PROC*)&py3_Py_IncRef},
+# endif
+# endif
# ifdef USE_LIMITED_API
{"Py_CompileString", (PYTHON_PROC*)&py3_Py_CompileString},
{"PyEval_EvalCode", (PYTHON_PROC*)&PyEval_EvalCode},
@@ -774,6 +802,20 @@ py3__Py_XDECREF(PyObject *op)
# define Py_XDECREF(op) py3__Py_XDECREF(_PyObject_CAST(op))
# endif
+# if defined(USE_LIMITED_API) \
+ && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))
+ static inline void
+py3__Py_XINCREF(PyObject *op)
+{
+ if (op != NULL)
+ {
+ Py_INCREF(op);
+ }
+}
+# undef Py_XINCREF
+# define Py_XINCREF(op) py3__Py_XINCREF(_PyObject_CAST(op))
+# endif
+
# if PY_VERSION_HEX >= 0x030900b0
static inline int
py3_PyType_HasFeature(PyTypeObject *type, unsigned long feature)
@@ -1079,7 +1121,7 @@ static int python_end_called = FALSE;
#ifdef USE_LIMITED_API
# define DESTRUCTOR_FINISH(self) \
- ((freefunc)PyType_GetSlot(Py_TYPE(self), Py_tp_free))((PyObject*)self)
+ ((freefunc)PyType_GetSlot(Py_TYPE((PyObject*)self), Py_tp_free))((PyObject*)self)
#else
# define DESTRUCTOR_FINISH(self) Py_TYPE(self)->tp_free((PyObject*)self)
#endif
diff --git a/src/version.c b/src/version.c
index 444a1b2685..965a20dc8c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 668,
+/**/
667,
/**/
666,