Skip to content
Snippets Groups Projects
Commit 4894c09b authored by David Gobbi's avatar David Gobbi
Browse files

Remove PyEval methods deprecated in Python 3.9

parent 860eb883
No related branches found
No related tags found
No related merge requests found
......@@ -248,11 +248,16 @@ bool vtkPythonInterpreter::Initialize(int initsigs /*=0*/)
PySys_SetArgvEx(0, nullptr, 0);
#ifdef VTK_PYTHON_FULL_THREADSAFE
#if PY_VERSION_HEX < 0x03090000
// In Python 3.9 and higher, PyEval_ThreadsInitialized() and
// PyEval_InitThreads() are deprecated and do nothing.
// GIL initialization is handled by Py_InitializeEx().
int threadInit = PyEval_ThreadsInitialized();
if (!threadInit)
{
PyEval_InitThreads(); // initialize and acquire GIL
}
#endif
// Always release GIL, as it has been acquired either by PyEval_InitThreads
// prior to Python 3.7 or by Py_InitializeEx in Python 3.7 and after
PyEval_SaveThread();
......
......@@ -234,7 +234,7 @@ void vtkPythonCommand::Execute(vtkObject* ptr, unsigned long eventtype, void* ca
arglist = Py_BuildValue("(Ns)", obj2, eventname);
}
PyObject* result = PyEval_CallObject(this->obj, arglist);
PyObject* result = PyObject_Call(this->obj, arglist, nullptr);
Py_DECREF(arglist);
if (result)
......
......@@ -564,7 +564,7 @@ vtkObjectBase* vtkPythonUtil::GetPointerFromObject(PyObject* obj, const char* re
if (obj)
{
PyObject* arglist = Py_BuildValue("()");
PyObject* result = PyEval_CallObject(obj, arglist);
PyObject* result = PyObject_Call(obj, arglist, nullptr);
Py_DECREF(arglist);
Py_DECREF(obj);
if (result == nullptr)
......@@ -1083,7 +1083,7 @@ void vtkPythonVoidFunc(void* arg)
arglist = Py_BuildValue("()");
result = PyEval_CallObject(func, arglist);
result = PyObject_Call(func, arglist, nullptr);
Py_DECREF(arglist);
if (result)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment