From ccb304fa1360a198cc0246b2fcf203595793ccc5 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 15 Dec 2020 18:23:40 -0500 Subject: [PATCH] Remove deprecated PyEval_InitThreads() not needed by Python > 3.6 --- src/PYTHON/python_impl.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/PYTHON/python_impl.cpp b/src/PYTHON/python_impl.cpp index 22bf8e77fb..1b3fabfa62 100644 --- a/src/PYTHON/python_impl.cpp +++ b/src/PYTHON/python_impl.cpp @@ -53,7 +53,15 @@ PythonImpl::PythonImpl(LAMMPS *lmp) : Pointers(lmp) external_interpreter = Py_IsInitialized(); Py_Initialize(); - PyEval_InitThreads(); + + // only needed for Python 2.x and Python 3 < 3.7 + // With Python 3.7 this function is now called by Py_Initialize() + // Deprecated since version 3.9, will be removed in version 3.11 +#if PY_MAJOR_VERSION < 3 || PY_MINOR_VERSION < 7 + if(!PyEval_ThreadsInitialized()) { + PyEval_InitThreads(); + } +#endif PyGILState_STATE gstate = PyGILState_Ensure();