From 75aaa036dda345154c21d9699c37537ea9bfeeb1 Mon Sep 17 00:00:00 2001 From: Armin Rigo Date: Mon, 31 Aug 2020 19:30:46 +0200 Subject: Don't call PyEval_InitThreads() on CPython >= 3.7, where it should always be a no-op. It is explicitly deprecated in 3.9. --- cffi/_embedding.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'cffi') 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 -- cgit v1.2.1