From 54cb519dc97b682aa016763e1f64355b1cd355d8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 19 Nov 2020 23:27:46 +0200 Subject: [PATCH] panda: Remove PyEval_InitThreads calls when compiling against Python 3.9+ Closes #1053 --- panda/src/event/pythonTask.cxx | 6 +++--- panda/src/pipeline/pythonThread.cxx | 6 +++--- panda/src/putil/pythonCallbackObject.cxx | 11 ++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/panda/src/event/pythonTask.cxx b/panda/src/event/pythonTask.cxx index 8430d3d59d..23320bbb64 100644 --- a/panda/src/event/pythonTask.cxx +++ b/panda/src/event/pythonTask.cxx @@ -71,12 +71,12 @@ PythonTask(PyObject *func_or_coro, const std::string &name) : __dict__ = PyDict_New(); -#ifndef SIMPLE_THREADS +#if !defined(SIMPLE_THREADS) && defined(WITH_THREAD) && PY_VERSION_HEX < 0x03090000 // Ensure that the Python threading system is initialized and ready to go. -#ifdef WITH_THREAD // This symbol defined within Python.h + // WITH_THREAD symbol defined within Python.h + // PyEval_InitThreads is now a deprecated no-op in Python 3.9+ PyEval_InitThreads(); #endif -#endif } /** diff --git a/panda/src/pipeline/pythonThread.cxx b/panda/src/pipeline/pythonThread.cxx index 13b31e0539..066553eaea 100644 --- a/panda/src/pipeline/pythonThread.cxx +++ b/panda/src/pipeline/pythonThread.cxx @@ -38,12 +38,12 @@ PythonThread(PyObject *function, PyObject *args, set_args(args); -#ifndef SIMPLE_THREADS +#if !defined(SIMPLE_THREADS) && defined(WITH_THREAD) && PY_VERSION_HEX < 0x03090000 // Ensure that the Python threading system is initialized and ready to go. -#ifdef WITH_THREAD // This symbol defined within Python.h + // WITH_THREAD symbol defined within Python.h + // PyEval_InitThreads is now a deprecated no-op in Python 3.9+ PyEval_InitThreads(); #endif -#endif } /** diff --git a/panda/src/putil/pythonCallbackObject.cxx b/panda/src/putil/pythonCallbackObject.cxx index 262749074f..5e7af752ad 100644 --- a/panda/src/putil/pythonCallbackObject.cxx +++ b/panda/src/putil/pythonCallbackObject.cxx @@ -41,15 +41,16 @@ PythonCallbackObject(PyObject *function) { set_function(function); -#ifndef SIMPLE_THREADS +#if !defined(SIMPLE_THREADS) && defined(WITH_THREAD) // Ensure that the Python threading system is initialized and ready to go. -#ifdef WITH_THREAD // This symbol defined within Python.h - + // WITH_THREAD symbol defined within Python.h Py_Initialize(); +#if PY_VERSION_HEX < 0x03090000 + // PyEval_InitThreads is now a deprecated no-op in Python 3.9+ PyEval_InitThreads(); -#endif -#endif +#endif // PY_VERSION_HEX +#endif // WITH_THREAD } /**