1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
diff --git a/VTK/Utilities/PythonInterpreter/vtkPythonInterpreter.cxx b/VTK/Utilities/PythonInterpreter/vtkPythonInterpreter.cxx
index deff95758c2bc7c3436431441b1b278f356ff9bb..1e9b6e1214552f4f0c51935f312c544863eb3180 100644
--- a/VTK/Utilities/PythonInterpreter/vtkPythonInterpreter.cxx
+++ b/VTK/Utilities/PythonInterpreter/vtkPythonInterpreter.cxx
@@ -97,6 +97,7 @@ wchar_t* vtk_Py_UTF8ToWide(const char* arg)
return result;
}
+#if PY_VERSION_HEX < 0x03080000
std::string vtk_Py_WideToUTF8(const wchar_t* arg)
{
std::string result;
@@ -110,6 +111,7 @@ std::string vtk_Py_WideToUTF8(const wchar_t* arg)
return result;
}
+#endif
std::vector<vtkWeakPointer<vtkPythonInterpreter>>* GlobalInterpreters;
std::vector<std::string> PythonPaths;
@@ -335,12 +337,21 @@ void SetupPythonPaths(bool isolated, std::string vtklib, const char* landmark)
if (vtklib.empty())
{
VTKPY_DEBUG_MESSAGE(
- "`GetVTKVersion` library couldn't be found. Will use `Py_GetProgramName` next.");
+ "`GetVTKVersion` library couldn't be found. Will use `sys.executable` next.");
}
if (vtklib.empty())
{
+#if PY_VERSION_HEX >= 0x03080000
+ vtkPythonScopeGilEnsurer gilEnsurer;
+ PyObject* executable_path = PySys_GetObject("executable");
+ if (executable_path != Py_None)
+ {
+ vtklib = PyUnicode_AsUTF8AndSize(executable_path, nullptr);
+ }
+#else
vtklib = vtk_Py_WideToUTF8(Py_GetProgramName());
+#endif
}
vtklib = systools::CollapseFullPath(vtklib);
diff --git a/VTK/Wrapping/Python/vtkmodules/test/Testing.py b/VTK/Wrapping/Python/vtkmodules/test/Testing.py
index 2891474a6d41e444f449d792dbd2e86ebbdd7520..e0b8675a48b98f8ee113fe7470feaa92aa4566f2 100644
--- a/VTK/Wrapping/Python/vtkmodules/test/Testing.py
+++ b/VTK/Wrapping/Python/vtkmodules/test/Testing.py
@@ -515,8 +515,10 @@ def test(cases):
"""
# Make the test suites from the arguments.
suites = []
- for case in cases:
- suites.append(unittest.makeSuite(case[0], case[1]))
+ loader = unittest.TestLoader()
+ # the "name" is ignored (it was always just 'test')
+ for test,name in cases:
+ suites.append(loader.loadTestsFromTestCase(test))
test_suite = unittest.TestSuite(suites)
# Now run the tests.
diff --git a/VTK/Wrapping/PythonCore/PyVTKNamespace.cxx b/VTK/Wrapping/PythonCore/PyVTKNamespace.cxx
index bed60dc47cbeff3daaf4dd22618b11c1abc77334..c1823084086318f566ff388086fc7e040957fab3 100644
--- a/VTK/Wrapping/PythonCore/PyVTKNamespace.cxx
+++ b/VTK/Wrapping/PythonCore/PyVTKNamespace.cxx
@@ -112,8 +112,10 @@ PyObject* PyVTKNamespace_New(const char* name)
{
// make sure python has readied the type object
PyType_Ready(&PyVTKNamespace_Type);
- // call the allocator provided by python for this type
- self = PyVTKNamespace_Type.tp_alloc(&PyVTKNamespace_Type, 0);
+ // call the superclass new function
+ PyObject* empty = PyTuple_New(0);
+ self = PyVTKNamespace_Type.tp_base->tp_new(&PyVTKNamespace_Type, empty, nullptr);
+ Py_DECREF(empty);
// call the superclass init function
PyObject* pyname = PyUnicode_FromString(name);
PyObject* args = PyTuple_Pack(1, pyname);
diff --git a/VTK/Wrapping/PythonCore/PyVTKTemplate.cxx b/VTK/Wrapping/PythonCore/PyVTKTemplate.cxx
index 26421f60f07ccece05a98f7f96090f968623902a..e7780bf10076af9fdabe728a31c5968b85ea43ed 100644
--- a/VTK/Wrapping/PythonCore/PyVTKTemplate.cxx
+++ b/VTK/Wrapping/PythonCore/PyVTKTemplate.cxx
@@ -761,8 +761,10 @@ PyObject* PyVTKTemplate_New(const char* name, const char* docstring)
{
// make sure python has readied the type object
PyType_Ready(&PyVTKTemplate_Type);
- // call the allocator provided by python for this type
- PyObject* self = PyVTKTemplate_Type.tp_alloc(&PyVTKTemplate_Type, 0);
+ // call the superclass new function
+ PyObject* empty = PyTuple_New(0);
+ PyObject* self = PyVTKTemplate_Type.tp_base->tp_new(&PyVTKTemplate_Type, empty, nullptr);
+ Py_DECREF(empty);
// call the superclass init function
PyObject* pyname = PyUnicode_FromString(name);
PyObject* pydoc = PyUnicode_FromString(docstring);
|