diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-10-11 18:05:02 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-10-11 18:05:02 +0200 |
commit | efc0d94afc48a03b07955e91315e7e67945cd079 (patch) | |
tree | 75e42d881bc5f83429372139eb0cb5f8d554fb59 /src/if_python3.c | |
parent | 204ade6bcb85f48f56e52e040d1ebf40548d92be (diff) | |
download | vim-git-efc0d94afc48a03b07955e91315e7e67945cd079.tar.gz |
patch 8.2.1834: PyEval_InitThreads() is deprecated in Python 3.9v8.2.1834
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.
Diffstat (limited to 'src/if_python3.c')
-rw-r--r-- | src/if_python3.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/if_python3.c b/src/if_python3.c index e148e53bb..495aed359 100644 --- a/src/if_python3.c +++ b/src/if_python3.c @@ -1002,11 +1002,10 @@ Python3_Init(void) reset_stdin(); 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 @@ -1024,12 +1023,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; |