diff options
author | Armin Rigo <arigo@tunes.org> | 2020-08-31 19:30:46 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2020-08-31 19:30:46 +0200 |
commit | 75aaa036dda345154c21d9699c37537ea9bfeeb1 (patch) | |
tree | 35c4cd8af7b8bf2e66ba2bf214bdc48e42ca82a3 /cffi | |
parent | 586159ad522758943ee5c794e583c214fab6084e (diff) | |
download | cffi-75aaa036dda345154c21d9699c37537ea9bfeeb1.tar.gz |
Don't call PyEval_InitThreads() on CPython >= 3.7, where it should always be a
no-op. It is explicitly deprecated in 3.9.
Diffstat (limited to 'cffi')
-rw-r--r-- | cffi/_embedding.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/cffi/_embedding.h b/cffi/_embedding.h index 207d683..456dc52 100644 --- a/cffi/_embedding.h +++ b/cffi/_embedding.h @@ -331,15 +331,20 @@ static int _cffi_carefully_make_gil(void) /* call Py_InitializeEx() */ if (!Py_IsInitialized()) { _cffi_py_initialize(); +#if PY_VERSION_HEX < 0x03070000 PyEval_InitThreads(); +#endif PyEval_SaveThread(); /* release the GIL */ /* the returned tstate must be the one that has been stored into the autoTLSkey by _PyGILState_Init() called from Py_Initialize(). */ } else { +#if PY_VERSION_HEX < 0x03070000 + /* PyEval_InitThreads() is always a no-op from CPython 3.7 */ PyGILState_STATE state = PyGILState_Ensure(); PyEval_InitThreads(); PyGILState_Release(state); +#endif } #ifdef WITH_THREAD |