!57 fix build fail for python3-3.10.0

From: @tong_1001
Reviewed-by: @xiezhipeng1
Signed-off-by: @xiezhipeng1
This commit is contained in:
openeuler-ci-bot 2021-11-27 06:55:30 +00:00 committed by Gitee
commit fccf296a66
6 changed files with 365 additions and 2 deletions

View File

@ -0,0 +1,90 @@
From efc0d94afc48a03b07955e91315e7e67945cd079 Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
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

View File

@ -0,0 +1,23 @@
From a65bb53514a1af1ec0dc5c4831dfaef69f139a48 Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
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

View File

@ -0,0 +1,38 @@
From 23c0192166760b0d73bd39252ca72e3cfe596f6e Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
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

View File

@ -0,0 +1,136 @@
From ee1b93169d21896e5401a54a5189c9465abb7bc9 Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
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

View File

@ -0,0 +1,65 @@
From 90478f35a8c78e2e10a4b4a8f135998dc04c91fa Mon Sep 17 00:00:00 2001
From: Zdenek Dohnal <zdohnal@redhat.com>
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

View File

@ -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<shixuantong@huawei> - 2:8.2-15
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix build fail for python3-3.10.0
* Sat Nov 13 2021 shixuantong<shixuantong@huawei> - 2:8.2-14
- Type:CVE
- ID:CVE-2021-3927 CVE-2021-3927