mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
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.
This commit is contained in:
@@ -307,7 +307,7 @@ ObjectDir(PyObject *self, char **attributes)
|
|||||||
// Output buffer management
|
// Output buffer management
|
||||||
|
|
||||||
// Function to write a line, points to either msg() or emsg().
|
// Function to write a line, points to either msg() or emsg().
|
||||||
typedef void (*writefn)(char_u *);
|
typedef int (*writefn)(char *);
|
||||||
|
|
||||||
static PyTypeObject OutputType;
|
static PyTypeObject OutputType;
|
||||||
|
|
||||||
@@ -359,8 +359,8 @@ PythonIO_Flush(void)
|
|||||||
{
|
{
|
||||||
if (old_fn != NULL && io_ga.ga_len > 0)
|
if (old_fn != NULL && io_ga.ga_len > 0)
|
||||||
{
|
{
|
||||||
((char_u *)io_ga.ga_data)[io_ga.ga_len] = NUL;
|
((char *)io_ga.ga_data)[io_ga.ga_len] = NUL;
|
||||||
old_fn((char_u *)io_ga.ga_data);
|
old_fn((char *)io_ga.ga_data);
|
||||||
}
|
}
|
||||||
io_ga.ga_len = 0;
|
io_ga.ga_len = 0;
|
||||||
}
|
}
|
||||||
@@ -390,7 +390,7 @@ writer(writefn fn, char_u *str, PyInt n)
|
|||||||
|
|
||||||
mch_memmove(((char *)io_ga.ga_data) + io_ga.ga_len, str, (size_t)len);
|
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;
|
((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;
|
str = ptr + 1;
|
||||||
n -= len + 1;
|
n -= len + 1;
|
||||||
io_ga.ga_len = 0;
|
io_ga.ga_len = 0;
|
||||||
|
@@ -1002,11 +1002,10 @@ Python3_Init(void)
|
|||||||
reset_stdin();
|
reset_stdin();
|
||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
|
|
||||||
// Initialise threads, and below save the state using
|
#if PY_VERSION_HEX < 0x03090000
|
||||||
// PyEval_SaveThread. Without the call to PyEval_SaveThread, thread
|
// Initialise threads. This is deprecated since Python 3.9.
|
||||||
// specific state (such as the system trace hook), will be lost
|
|
||||||
// between invocations of Python code.
|
|
||||||
PyEval_InitThreads();
|
PyEval_InitThreads();
|
||||||
|
#endif
|
||||||
#ifdef DYNAMIC_PYTHON3
|
#ifdef DYNAMIC_PYTHON3
|
||||||
get_py3_exceptions();
|
get_py3_exceptions();
|
||||||
#endif
|
#endif
|
||||||
@@ -1024,12 +1023,14 @@ Python3_Init(void)
|
|||||||
// sys.path.
|
// sys.path.
|
||||||
PyRun_SimpleString("import vim; import sys; sys.path = list(filter(lambda x: not x.endswith('must>not&exist'), 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
|
// Without the call to PyEval_SaveThread, thread specific state (such
|
||||||
// state is created in Py_Initialize()
|
// as the system trace hook), will be lost between invocations of
|
||||||
// there _PyGILState_NoteThreadState() also sets gilcounter to 1
|
// Python code.
|
||||||
// (python must have threads enabled!)
|
// GIL may have been created and acquired in PyEval_InitThreads() and
|
||||||
// so the following does both: unlock GIL and save thread state in TLS
|
// thread state is created in Py_Initialize(); there
|
||||||
// without deleting thread state
|
// _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();
|
PyEval_SaveThread();
|
||||||
|
|
||||||
py3initialised = 1;
|
py3initialised = 1;
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1834,
|
||||||
/**/
|
/**/
|
||||||
1833,
|
1833,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user