diff --git a/backport-PyEval_InitThreads-is-deprecated-in-Python-3.9.patch b/backport-PyEval_InitThreads-is-deprecated-in-Python-3.9.patch new file mode 100644 index 0000000000000000000000000000000000000000..dafa29aa968cdcdb7569007815b792b0a51491ba --- /dev/null +++ b/backport-PyEval_InitThreads-is-deprecated-in-Python-3.9.patch @@ -0,0 +1,90 @@ +From efc0d94afc48a03b07955e91315e7e67945cd079 Mon Sep 17 00:00:00 2001 +From: Bram Moolenaar +Date: Sun, 11 Oct 2020 18:05:02 +0200 +Subject: [PATCH] patch 8.2.1834: PyEval_InitThreads() is deprecated in Python + 3.9 + +Problem: PyEval_InitThreads() is deprecated in Python 3.9. +Solution: Do not call PyEval_InitThreads in Python 3.9 and later. (Ken +Takata, closes #7113) Avoid warnings for functions. +--- + src/if_py_both.h | 8 ++++---- + src/if_python3.c | 21 +++++++++++---------- + 2 files changed, 15 insertions(+), 14 deletions(-) + +diff --git a/src/if_py_both.h b/src/if_py_both.h +index 0763c65..63f4329 100644 +--- a/src/if_py_both.h ++++ b/src/if_py_both.h +@@ -306,7 +306,7 @@ ObjectDir(PyObject *self, char **attributes) + // Output buffer management + + // Function to write a line, points to either msg() or emsg(). +-typedef void (*writefn)(char_u *); ++typedef int (*writefn)(char *); + + static PyTypeObject OutputType; + +@@ -358,8 +358,8 @@ PythonIO_Flush(void) + { + if (old_fn != NULL && io_ga.ga_len > 0) + { +- ((char_u *)io_ga.ga_data)[io_ga.ga_len] = NUL; +- old_fn((char_u *)io_ga.ga_data); ++ ((char *)io_ga.ga_data)[io_ga.ga_len] = NUL; ++ old_fn((char *)io_ga.ga_data); + } + io_ga.ga_len = 0; + } +@@ -389,7 +389,7 @@ writer(writefn fn, char_u *str, PyInt n) + + mch_memmove(((char *)io_ga.ga_data) + io_ga.ga_len, str, (size_t)len); + ((char *)io_ga.ga_data)[io_ga.ga_len + len] = NUL; +- fn((char_u *)io_ga.ga_data); ++ fn((char *)io_ga.ga_data); + str = ptr + 1; + n -= len + 1; + io_ga.ga_len = 0; +diff --git a/src/if_python3.c b/src/if_python3.c +index 45dc308..7c9e140 100644 +--- a/src/if_python3.c ++++ b/src/if_python3.c +@@ -958,11 +958,10 @@ Python3_Init(void) + + Py_Initialize(); + +- // Initialise threads, and below save the state using +- // PyEval_SaveThread. Without the call to PyEval_SaveThread, thread +- // specific state (such as the system trace hook), will be lost +- // between invocations of Python code. ++#if PY_VERSION_HEX < 0x03090000 ++ // Initialise threads. This is deprecated since Python 3.9. + PyEval_InitThreads(); ++#endif + #ifdef DYNAMIC_PYTHON3 + get_py3_exceptions(); + #endif +@@ -980,12 +979,14 @@ Python3_Init(void) + // sys.path. + PyRun_SimpleString("import vim; import sys; sys.path = list(filter(lambda x: not x.endswith('must>not&exist'), sys.path))"); + +- // lock is created and acquired in PyEval_InitThreads() and thread +- // state is created in Py_Initialize() +- // there _PyGILState_NoteThreadState() also sets gilcounter to 1 +- // (python must have threads enabled!) +- // so the following does both: unlock GIL and save thread state in TLS +- // without deleting thread state ++ // Without the call to PyEval_SaveThread, thread specific state (such ++ // as the system trace hook), will be lost between invocations of ++ // Python code. ++ // GIL may have been created and acquired in PyEval_InitThreads() and ++ // thread state is created in Py_Initialize(); there ++ // _PyGILState_NoteThreadState() also sets gilcounter to 1 (python must ++ // have threads enabled!), so the following does both: unlock GIL and ++ // save thread state in TLS without deleting thread state + PyEval_SaveThread(); + + py3initialised = 1; +-- +1.8.3.1 + diff --git a/backport-Python-3.9-does-not-define-_Py_DEC_REFTOTAL.patch b/backport-Python-3.9-does-not-define-_Py_DEC_REFTOTAL.patch new file mode 100644 index 0000000000000000000000000000000000000000..aeab420a9708d1ba105cac780cc27b738118ff66 --- /dev/null +++ b/backport-Python-3.9-does-not-define-_Py_DEC_REFTOTAL.patch @@ -0,0 +1,23 @@ +From a65bb53514a1af1ec0dc5c4831dfaef69f139a48 Mon Sep 17 00:00:00 2001 +From: Bram Moolenaar +Date: Wed, 4 Mar 2020 22:06:07 +0100 +Subject: [PATCH] patch 8.2.0354: Python 3.9 does not define _Py_DEC_REFTOTAL + +Problem: Python 3.9 does not define _Py_DEC_REFTOTAL. (Zdenek Dohnal) +Solution: Remove it, it was only for debugging. +--- + src/if_python3.c | 1 - + 1 files changed, 1 deletion(-) + +diff --git a/src/if_python3.c b/src/if_python3.c +index 6e4b81acd0e..2985e9c894b 100644 +--- a/src/if_python3.c ++++ b/src/if_python3.c +@@ -603,7 +603,6 @@ static struct + static inline void + py3__Py_DECREF(const char *filename UNUSED, int lineno UNUSED, PyObject *op) + { +- _Py_DEC_REFTOTAL; + if (--op->ob_refcnt != 0) + { + # ifdef Py_REF_DEBUG diff --git a/backport-configure-cannot-detect-Python-3.10.patch b/backport-configure-cannot-detect-Python-3.10.patch new file mode 100644 index 0000000000000000000000000000000000000000..23002b86bfa36dbacae3897ff900024fb26ef1db --- /dev/null +++ b/backport-configure-cannot-detect-Python-3.10.patch @@ -0,0 +1,38 @@ +From 23c0192166760b0d73bd39252ca72e3cfe596f6e Mon Sep 17 00:00:00 2001 +From: Bram Moolenaar +Date: Fri, 21 May 2021 11:43:58 +0200 +Subject: [PATCH] patch 8.2.2876: configure cannot detect Python 3.10 + +Problem: Configure cannot detect Python 3.10. +Solution: Use sys.version_info. (closes #8233) +--- + src/auto/configure | 2 +- + src/configure.ac | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/auto/configure b/src/auto/configure +index 0b423a65775..5702a217188 100755 +--- a/src/auto/configure ++++ b/src/auto/configure +@@ -6673,7 +6673,7 @@ if ${vi_cv_var_python3_version+:} false; then : + $as_echo_n "(cached) " >&6 + else + vi_cv_var_python3_version=` +- ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'` ++ ${vi_cv_path_python3} -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))'` + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_var_python3_version" >&5 +diff --git a/src/configure.ac b/src/configure.ac +index cc8d61f7f8b..2db04496ff1 100644 +--- a/src/configure.ac ++++ b/src/configure.ac +@@ -1436,7 +1436,7 @@ if test "$enable_python3interp" = "yes" -o "$enable_python3interp" = "dynamic"; + dnl -- get its version number + AC_CACHE_CHECK(Python version,vi_cv_var_python3_version, + [[vi_cv_var_python3_version=` +- ${vi_cv_path_python3} -c 'import sys; print(sys.version[:3])'` ++ ${vi_cv_path_python3} -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))'` + ]]) + + dnl -- it must be at least version 3 diff --git a/backport-linker-errors-when-building-with-dynamic-Python-3.9.patch b/backport-linker-errors-when-building-with-dynamic-Python-3.9.patch new file mode 100644 index 0000000000000000000000000000000000000000..bd22bd57f14875ad85fce2c76677822dedd4a258 --- /dev/null +++ b/backport-linker-errors-when-building-with-dynamic-Python-3.9.patch @@ -0,0 +1,136 @@ +From ee1b93169d21896e5401a54a5189c9465abb7bc9 Mon Sep 17 00:00:00 2001 +From: Bram Moolenaar +Date: Thu, 16 Jul 2020 22:15:53 +0200 +Subject: [PATCH] patch 8.2.1225: linker errors when building with dynamic + Python 3.9 + +Problem: Linker errors when building with dynamic Python 3.9. +Solution: Add #defined items. (closes #6461) +--- + src/if_python3.c | 40 +++++++++++++++++++++++++++++++++++++--- + 1 file changed, 37 insertions(+), 3 deletions(-) + +diff --git a/src/if_python3.c b/src/if_python3.c +index 68da288..45dc308 100644 +--- a/src/if_python3.c ++++ b/src/if_python3.c +@@ -203,6 +203,9 @@ typedef PySliceObject PySliceObject_T; + # define PySys_GetObject py3_PySys_GetObject + # define PySys_SetArgv py3_PySys_SetArgv + # define PyType_Ready py3_PyType_Ready ++# if PY_VERSION_HEX >= 0x030900b0 ++# define PyType_GetFlags py3_PyType_GetFlags ++# endif + #undef Py_BuildValue + # define Py_BuildValue py3_Py_BuildValue + # define Py_SetPythonHome py3_Py_SetPythonHome +@@ -233,6 +236,9 @@ typedef PySliceObject PySliceObject_T; + # define PyBytes_FromString py3_PyBytes_FromString + # undef PyBytes_FromStringAndSize + # define PyBytes_FromStringAndSize py3_PyBytes_FromStringAndSize ++# if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030900b0 ++# define _Py_Dealloc py3__Py_Dealloc ++# endif + # define PyFloat_FromDouble py3_PyFloat_FromDouble + # define PyFloat_AsDouble py3_PyFloat_AsDouble + # define PyObject_GenericGetAttr py3_PyObject_GenericGetAttr +@@ -247,7 +253,6 @@ typedef PySliceObject PySliceObject_T; + # ifdef Py_DEBUG + # define _Py_NegativeRefcount py3__Py_NegativeRefcount + # define _Py_RefTotal (*py3__Py_RefTotal) +-# define _Py_Dealloc py3__Py_Dealloc + # define PyModule_Create2TraceRefs py3_PyModule_Create2TraceRefs + # else + # define PyModule_Create2 py3_PyModule_Create2 +@@ -287,6 +292,10 @@ typedef PySliceObject PySliceObject_T; + # define PyObject_NEW(type, typeobj) \ + ( (type *) PyObject_Init( \ + (PyObject *) _PyObject_DebugMalloc( _PyObject_SIZE(typeobj) ), (typeobj)) ) ++# elif PY_VERSION_HEX >= 0x030900b0 ++# undef PyObject_NEW ++# define PyObject_NEW(type, typeobj) \ ++ ((type *)py3__PyObject_New(typeobj)) + # endif + + /* +@@ -352,6 +361,9 @@ static PyObject* (*py3_PyObject_Repr)(PyObject *); + static PyObject* (*py3_PyObject_GetItem)(PyObject *, PyObject *); + static int (*py3_PyObject_IsTrue)(PyObject *); + static PyObject* (*py3_Py_BuildValue)(char *, ...); ++# if PY_VERSION_HEX >= 0x030900b0 ++static int (*py3_PyType_GetFlags)(PyTypeObject *o); ++# endif + static int (*py3_PyType_Ready)(PyTypeObject *type); + static int (*py3_PyDict_SetItemString)(PyObject *dp, char *key, PyObject *item); + static PyObject* (*py3_PyUnicode_FromString)(const char *u); +@@ -396,6 +408,12 @@ static char* (*py3_PyBytes_AsString)(PyObject *bytes); + static int (*py3_PyBytes_AsStringAndSize)(PyObject *bytes, char **buffer, Py_ssize_t *length); + static PyObject* (*py3_PyBytes_FromString)(char *str); + static PyObject* (*py3_PyBytes_FromStringAndSize)(char *str, Py_ssize_t length); ++# if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030900b0 ++static void (*py3__Py_Dealloc)(PyObject *obj); ++# endif ++# if PY_VERSION_HEX >= 0x030900b0 ++static PyObject* (*py3__PyObject_New)(PyTypeObject *); ++# endif + static PyObject* (*py3_PyFloat_FromDouble)(double num); + static double (*py3_PyFloat_AsDouble)(PyObject *); + static PyObject* (*py3_PyObject_GenericGetAttr)(PyObject *obj, PyObject *name); +@@ -414,7 +432,6 @@ static void* (*py3_PyCapsule_GetPointer)(PyObject *, char *); + # ifdef Py_DEBUG + static void (*py3__Py_NegativeRefcount)(const char *fname, int lineno, PyObject *op); + static Py_ssize_t* py3__Py_RefTotal; +-static void (*py3__Py_Dealloc)(PyObject *obj); + static PyObject* (*py3_PyModule_Create2TraceRefs)(struct PyModuleDef* module, int module_api_version); + # else + static PyObject* (*py3_PyModule_Create2)(struct PyModuleDef* module, int module_api_version); +@@ -525,6 +542,9 @@ static struct + {"PyObject_IsTrue", (PYTHON_PROC*)&py3_PyObject_IsTrue}, + {"PyLong_FromLong", (PYTHON_PROC*)&py3_PyLong_FromLong}, + {"PyDict_New", (PYTHON_PROC*)&py3_PyDict_New}, ++# if PY_VERSION_HEX >= 0x030900b0 ++ {"PyType_GetFlags", (PYTHON_PROC*)&py3_PyType_GetFlags}, ++# endif + {"PyType_Ready", (PYTHON_PROC*)&py3_PyType_Ready}, + {"PyDict_SetItemString", (PYTHON_PROC*)&py3_PyDict_SetItemString}, + {"PyLong_AsLong", (PYTHON_PROC*)&py3_PyLong_AsLong}, +@@ -562,6 +582,12 @@ static struct + {"PyBytes_AsStringAndSize", (PYTHON_PROC*)&py3_PyBytes_AsStringAndSize}, + {"PyBytes_FromString", (PYTHON_PROC*)&py3_PyBytes_FromString}, + {"PyBytes_FromStringAndSize", (PYTHON_PROC*)&py3_PyBytes_FromStringAndSize}, ++# if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030900b0 ++ {"_Py_Dealloc", (PYTHON_PROC*)&py3__Py_Dealloc}, ++# endif ++# if PY_VERSION_HEX >= 0x030900b0 ++ {"_PyObject_New", (PYTHON_PROC*)&py3__PyObject_New}, ++# endif + {"PyFloat_FromDouble", (PYTHON_PROC*)&py3_PyFloat_FromDouble}, + {"PyFloat_AsDouble", (PYTHON_PROC*)&py3_PyFloat_AsDouble}, + {"PyObject_GenericGetAttr", (PYTHON_PROC*)&py3_PyObject_GenericGetAttr}, +@@ -578,7 +604,6 @@ static struct + # ifdef Py_DEBUG + {"_Py_NegativeRefcount", (PYTHON_PROC*)&py3__Py_NegativeRefcount}, + {"_Py_RefTotal", (PYTHON_PROC*)&py3__Py_RefTotal}, +- {"_Py_Dealloc", (PYTHON_PROC*)&py3__Py_Dealloc}, + {"PyModule_Create2TraceRefs", (PYTHON_PROC*)&py3_PyModule_Create2TraceRefs}, + # else + {"PyModule_Create2", (PYTHON_PROC*)&py3_PyModule_Create2}, +@@ -634,6 +659,15 @@ py3__Py_XDECREF(PyObject *op) + # define Py_XDECREF(op) py3__Py_XDECREF(_PyObject_CAST(op)) + # endif + ++# if PY_VERSION_HEX >= 0x030900b0 ++ static inline int ++py3_PyType_HasFeature(PyTypeObject *type, unsigned long feature) ++{ ++ return ((PyType_GetFlags(type) & feature) != 0); ++} ++# define PyType_HasFeature(t,f) py3_PyType_HasFeature(t,f) ++# endif ++ + /* + * Free python.dll + */ +-- +1.8.3.1 + diff --git a/backport-linker-errors-with-dynamic-Python-3.10.patch b/backport-linker-errors-with-dynamic-Python-3.10.patch new file mode 100644 index 0000000000000000000000000000000000000000..51150cf55ce0d26378b1a276338b5a522ad8c746 --- /dev/null +++ b/backport-linker-errors-with-dynamic-Python-3.10.patch @@ -0,0 +1,65 @@ +From 90478f35a8c78e2e10a4b4a8f135998dc04c91fa Mon Sep 17 00:00:00 2001 +From: Zdenek Dohnal +Date: Mon, 14 Jun 2021 15:08:30 +0200 +Subject: [PATCH] patch 8.2.2995: linker errors with dynamic Python 3.10 + +Problem: Linker errors with dynamic Python 3.10. +Solution: Add a couple of library entries. (Zdenek Dohnal, closes #8381, +closes #8356) +--- + src/if_python3.c | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/src/if_python3.c b/src/if_python3.c +index 7c9e140..72c9e9b 100644 +--- a/src/if_python3.c ++++ b/src/if_python3.c +@@ -181,6 +181,9 @@ typedef PySliceObject PySliceObject_T; + # ifndef PyMapping_Keys + # define PyMapping_Keys py3_PyMapping_Keys + # endif ++# if PY_VERSION_HEX >= 0x030a00b2 ++# define PyIter_Check py3_PyIter_Check ++# endif + # define PyIter_Next py3_PyIter_Next + # define PyObject_GetIter py3_PyObject_GetIter + # define PyObject_Repr py3_PyObject_Repr +@@ -355,6 +358,9 @@ static PyObject* (*py3_PyDict_GetItemString)(PyObject *, const char *); + static int (*py3_PyDict_Next)(PyObject *, Py_ssize_t *, PyObject **, PyObject **); + static PyObject* (*py3_PyLong_FromLong)(long); + static PyObject* (*py3_PyDict_New)(void); ++# if PY_VERSION_HEX >= 0x030a00b2 ++static int (*py3_PyIter_Check)(PyObject *o); ++# endif + static PyObject* (*py3_PyIter_Next)(PyObject *); + static PyObject* (*py3_PyObject_GetIter)(PyObject *); + static PyObject* (*py3_PyObject_Repr)(PyObject *); +@@ -535,6 +541,9 @@ static struct + {"PyDict_Next", (PYTHON_PROC*)&py3_PyDict_Next}, + {"PyMapping_Check", (PYTHON_PROC*)&py3_PyMapping_Check}, + {"PyMapping_Keys", (PYTHON_PROC*)&py3_PyMapping_Keys}, ++# if PY_VERSION_HEX >= 0x030a00b2 ++ {"PyIter_Check", (PYTHON_PROC*)&py3_PyIter_Check}, ++# endif + {"PyIter_Next", (PYTHON_PROC*)&py3_PyIter_Next}, + {"PyObject_GetIter", (PYTHON_PROC*)&py3_PyObject_GetIter}, + {"PyObject_Repr", (PYTHON_PROC*)&py3_PyObject_Repr}, +@@ -668,6 +677,15 @@ py3_PyType_HasFeature(PyTypeObject *type, unsigned long feature) + # define PyType_HasFeature(t,f) py3_PyType_HasFeature(t,f) + # endif + ++# if PY_VERSION_HEX >= 0x030a00b2 ++ static inline int ++py3__PyObject_TypeCheck(PyObject *ob, PyTypeObject *type) ++{ ++ return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type); ++} ++# define _PyObject_TypeCheck(o,t) py3__PyObject_TypeCheck(o,t) ++# endif ++ + /* + * Free python.dll + */ +-- +1.8.3.1 + diff --git a/vim.spec b/vim.spec index ac2226f5083e7822d34daf2bed1705b6f64972c4..5e0078168ac4e9fc3bfdc762c95062806f35b1f4 100644 --- a/vim.spec +++ b/vim.spec @@ -7,12 +7,12 @@ %{!?_with_netbeans__:%define _with_netbeans__ 1} %define vimdir vim82 -%define python_ver 3.8 +%define python_ver %{python3_version} Name: vim Epoch: 2 Version: 8.2 -Release: 14 +Release: 15 Summary: Vim is a highly configurable text editor for efficiently creating and changing any kind of text. License: Vim and MIT URL: http://www.vim.org @@ -45,6 +45,11 @@ Patch6007: backport-CVE-2021-3875.patch Patch6008: backport-CVE-2021-3903.patch Patch6009: backport-CVE-2021-3927.patch Patch6010: backport-CVE-2021-3928.patch +Patch6011: backport-Python-3.9-does-not-define-_Py_DEC_REFTOTAL.patch +Patch6012: backport-linker-errors-when-building-with-dynamic-Python-3.9.patch +Patch6013: backport-PyEval_InitThreads-is-deprecated-in-Python-3.9.patch +Patch6014: backport-linker-errors-with-dynamic-Python-3.10.patch +Patch6015: backport-configure-cannot-detect-Python-3.10.patch Patch9000: bugfix-rm-modify-info-version.patch @@ -433,6 +438,12 @@ popd %{_mandir}/man1/evim.* %changelog +* Sat Nov 27 2021 shixuantong - 2:8.2-15 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:fix build fail for python3-3.10.0 + * Sat Nov 13 2021 shixuantong - 2:8.2-14 - Type:CVE - ID:CVE-2021-3927 CVE-2021-3927