99cfd9f
From 257b9d7b18d5f3db3fe099dc18f230e23f7dfbab Mon Sep 17 00:00:00 2001
99cfd9f
From: David Gobbi <david.gobbi@gmail.com>
99cfd9f
Date: Tue, 20 Aug 2019 17:02:24 -0600
99cfd9f
Subject: [PATCH] Compatibility for Python 3.8
99cfd9f
99cfd9f
The PyTypeObject struct was modified in Python 3.8, this change is
99cfd9f
required to avoid compile errors.
99cfd9f
---
99cfd9f
 .../PythonInterpreter/vtkPythonStdStreamCaptureHelper.h   | 6 ++++++
99cfd9f
 Wrapping/PythonCore/PyVTKMethodDescriptor.cxx             | 2 +-
99cfd9f
 Wrapping/PythonCore/PyVTKNamespace.cxx                    | 2 +-
99cfd9f
 Wrapping/PythonCore/PyVTKReference.cxx                    | 8 ++++----
99cfd9f
 Wrapping/PythonCore/PyVTKTemplate.cxx                     | 2 +-
99cfd9f
 Wrapping/PythonCore/vtkPythonCompatibility.h              | 8 +++++++-
99cfd9f
 Wrapping/Tools/vtkWrapPythonClass.c                       | 2 +-
99cfd9f
 Wrapping/Tools/vtkWrapPythonEnum.c                        | 2 +-
99cfd9f
 Wrapping/Tools/vtkWrapPythonType.c                        | 2 +-
99cfd9f
 9 files changed, 23 insertions(+), 11 deletions(-)
99cfd9f
99cfd9f
diff --git a/VTK/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h b/VTK/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h
99cfd9f
index b1c12c83de..14ccfbe928 100644
99cfd9f
--- a/VTK/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h
99cfd9f
+++ b/VTK/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h
99cfd9f
@@ -140,6 +140,12 @@ static PyTypeObject vtkPythonStdStreamCaptureHelperType = {
99cfd9f
 #if PY_VERSION_HEX >= 0x03040000
99cfd9f
   0, // tp_finalize
99cfd9f
 #endif
99cfd9f
+#if PY_VERSION_HEX >= 0x03080000
99cfd9f
+  0, // tp_vectorcall
99cfd9f
+#if PY_VERSION_HEX < 0x03090000
99cfd9f
+  0, // tp_print
99cfd9f
+#endif
99cfd9f
+#endif
99cfd9f
 };
99cfd9f
 
99cfd9f
 static PyObject* vtkWrite(PyObject* self, PyObject* args)
99cfd9f
diff --git a/VTK/Wrapping/PythonCore/PyVTKMethodDescriptor.cxx b/VTK/Wrapping/PythonCore/PyVTKMethodDescriptor.cxx
99cfd9f
index 2b0d443537..3840038498 100644
99cfd9f
--- a/VTK/Wrapping/PythonCore/PyVTKMethodDescriptor.cxx
99cfd9f
+++ b/VTK/Wrapping/PythonCore/PyVTKMethodDescriptor.cxx
99cfd9f
@@ -186,7 +186,7 @@ PyTypeObject PyVTKMethodDescriptor_Type = {
99cfd9f
   sizeof(PyMethodDescrObject),           // tp_basicsize
99cfd9f
   0,                                     // tp_itemsize
99cfd9f
   PyVTKMethodDescriptor_Delete,          // tp_dealloc
99cfd9f
-  nullptr,                               // tp_print
99cfd9f
+  0,                                     // tp_vectorcall_offset
99cfd9f
   nullptr,                               // tp_getattr
99cfd9f
   nullptr,                               // tp_setattr
99cfd9f
   nullptr,                               // tp_compare
99cfd9f
diff --git a/VTK/Wrapping/PythonCore/PyVTKNamespace.cxx b/VTK/Wrapping/PythonCore/PyVTKNamespace.cxx
99cfd9f
index 71ee2a3516..5cf5bfbe6b 100644
99cfd9f
--- a/VTK/Wrapping/PythonCore/PyVTKNamespace.cxx
99cfd9f
+++ b/VTK/Wrapping/PythonCore/PyVTKNamespace.cxx
99cfd9f
@@ -49,7 +49,7 @@ PyTypeObject PyVTKNamespace_Type = {
99cfd9f
   0,                                     // tp_basicsize
99cfd9f
   0,                                     // tp_itemsize
99cfd9f
   PyVTKNamespace_Delete,                 // tp_dealloc
99cfd9f
-  nullptr,                               // tp_print
99cfd9f
+  0,                                     // tp_vectorcall_offset
99cfd9f
   nullptr,                               // tp_getattr
99cfd9f
   nullptr,                               // tp_setattr
99cfd9f
   nullptr,                               // tp_compare
99cfd9f
diff --git a/VTK/Wrapping/PythonCore/PyVTKReference.cxx b/VTK/Wrapping/PythonCore/PyVTKReference.cxx
99cfd9f
index 943ac71080..b7104091c0 100644
99cfd9f
--- a/VTK/Wrapping/PythonCore/PyVTKReference.cxx
99cfd9f
+++ b/VTK/Wrapping/PythonCore/PyVTKReference.cxx
99cfd9f
@@ -1010,7 +1010,7 @@ PyTypeObject PyVTKReference_Type = {
99cfd9f
   sizeof(PyVTKReference),                // tp_basicsize
99cfd9f
   0,                                     // tp_itemsize
99cfd9f
   PyVTKReference_Delete,                 // tp_dealloc
99cfd9f
-  nullptr,                               // tp_print
99cfd9f
+  0,                                     // tp_vectorcall_offset
99cfd9f
   nullptr,                               // tp_getattr
99cfd9f
   nullptr,                               // tp_setattr
99cfd9f
   nullptr,                               // tp_compare
99cfd9f
@@ -1067,7 +1067,7 @@ PyTypeObject PyVTKNumberReference_Type = {
99cfd9f
   sizeof(PyVTKReference),                // tp_basicsize
99cfd9f
   0,                                     // tp_itemsize
99cfd9f
   PyVTKReference_Delete,                 // tp_dealloc
99cfd9f
-  nullptr,                               // tp_print
99cfd9f
+  0,                                     // tp_vectorcall_offset
99cfd9f
   nullptr,                               // tp_getattr
99cfd9f
   nullptr,                               // tp_setattr
99cfd9f
   nullptr,                               // tp_compare
99cfd9f
@@ -1124,7 +1124,7 @@ PyTypeObject PyVTKStringReference_Type = {
99cfd9f
   sizeof(PyVTKReference),                // tp_basicsize
99cfd9f
   0,                                     // tp_itemsize
99cfd9f
   PyVTKReference_Delete,                 // tp_dealloc
99cfd9f
-  nullptr,                               // tp_print
99cfd9f
+  0,                                     // tp_vectorcall_offset
99cfd9f
   nullptr,                               // tp_getattr
99cfd9f
   nullptr,                               // tp_setattr
99cfd9f
   nullptr,                               // tp_compare
99cfd9f
@@ -1181,7 +1181,7 @@ PyTypeObject PyVTKTupleReference_Type = {
99cfd9f
   sizeof(PyVTKReference),                // tp_basicsize
99cfd9f
   0,                                     // tp_itemsize
99cfd9f
   PyVTKReference_Delete,                 // tp_dealloc
99cfd9f
-  nullptr,                               // tp_print
99cfd9f
+  0,                                     // tp_vectorcall_offset
99cfd9f
   nullptr,                               // tp_getattr
99cfd9f
   nullptr,                               // tp_setattr
99cfd9f
   nullptr,                               // tp_compare
99cfd9f
diff --git a/VTK/Wrapping/PythonCore/PyVTKTemplate.cxx b/VTK/Wrapping/PythonCore/PyVTKTemplate.cxx
99cfd9f
index be200985b3..340fe7953b 100644
99cfd9f
--- a/VTK/Wrapping/PythonCore/PyVTKTemplate.cxx
99cfd9f
+++ b/VTK/Wrapping/PythonCore/PyVTKTemplate.cxx
99cfd9f
@@ -268,7 +268,7 @@ PyTypeObject PyVTKTemplate_Type = {
99cfd9f
   0,                                     // tp_basicsize
99cfd9f
   0,                                     // tp_itemsize
99cfd9f
   nullptr,                               // tp_dealloc
99cfd9f
-  nullptr,                               // tp_print
99cfd9f
+  0,                                     // tp_vectorcall_offset
99cfd9f
   nullptr,                               // tp_getattr
99cfd9f
   nullptr,                               // tp_setattr
99cfd9f
   nullptr,                               // tp_compare
99cfd9f
diff --git a/VTK/Wrapping/PythonCore/vtkPythonCompatibility.h b/VTK/Wrapping/PythonCore/vtkPythonCompatibility.h
99cfd9f
index 4a767844a6..be208faeef 100644
99cfd9f
--- a/VTK/Wrapping/PythonCore/vtkPythonCompatibility.h
99cfd9f
+++ b/VTK/Wrapping/PythonCore/vtkPythonCompatibility.h
99cfd9f
@@ -64,7 +64,13 @@
99cfd9f
 #endif
99cfd9f
 
99cfd9f
 // PyTypeObject compatibility
99cfd9f
-#if PY_VERSION_HEX >= 0x03040000
99cfd9f
+#if PY_VERSION_HEX >= 0x03090000
99cfd9f
+#define VTK_WRAP_PYTHON_SUPPRESS_UNINITIALIZED \
99cfd9f
+  0, 0, 0, 0,
99cfd9f
+#elif PY_VERSION_HEX >= 0x03080000
99cfd9f
+#define VTK_WRAP_PYTHON_SUPPRESS_UNINITIALIZED \
99cfd9f
+  0, 0, 0, 0, 0,
99cfd9f
+#elif PY_VERSION_HEX >= 0x03040000
99cfd9f
 #define VTK_WRAP_PYTHON_SUPPRESS_UNINITIALIZED \
99cfd9f
   0, 0, 0,
99cfd9f
 #else
99cfd9f
diff --git a/VTK/Wrapping/Tools/vtkWrapPythonClass.c b/VTK/Wrapping/Tools/vtkWrapPythonClass.c
99cfd9f
index b1e45f8e80..4d558ea081 100644
99cfd9f
--- a/VTK/Wrapping/Tools/vtkWrapPythonClass.c
99cfd9f
+++ b/VTK/Wrapping/Tools/vtkWrapPythonClass.c
99cfd9f
@@ -521,7 +521,7 @@ void vtkWrapPython_GenerateObjectType(
99cfd9f
     "  sizeof(PyVTKObject), // tp_basicsize\n"
99cfd9f
     "  0, // tp_itemsize\n"
99cfd9f
     "  PyVTKObject_Delete, // tp_dealloc\n"
99cfd9f
-    "  nullptr, // tp_print\n"
99cfd9f
+    "  0, // tp_vectorcall_offset\n"
99cfd9f
     "  nullptr, // tp_getattr\n"
99cfd9f
     "  nullptr, // tp_setattr\n"
99cfd9f
     "  nullptr, // tp_compare\n"
99cfd9f
diff --git a/VTK/Wrapping/Tools/vtkWrapPythonEnum.c b/VTK/Wrapping/Tools/vtkWrapPythonEnum.c
99cfd9f
index b933702242..1249362854 100644
99cfd9f
--- a/VTK/Wrapping/Tools/vtkWrapPythonEnum.c
99cfd9f
+++ b/VTK/Wrapping/Tools/vtkWrapPythonEnum.c
99cfd9f
@@ -145,7 +145,7 @@ void vtkWrapPython_GenerateEnumType(
99cfd9f
     "  sizeof(PyIntObject), // tp_basicsize\n"
99cfd9f
     "  0, // tp_itemsize\n"
99cfd9f
     "  nullptr, // tp_dealloc\n"
99cfd9f
-    "  nullptr, // tp_print\n"
99cfd9f
+    "  0, // tp_vectorcall_offset\n"
99cfd9f
     "  nullptr, // tp_getattr\n"
99cfd9f
     "  nullptr, // tp_setattr\n"
99cfd9f
     "  nullptr, // tp_compare\n"
99cfd9f
diff --git a/VTK/Wrapping/Tools/vtkWrapPythonType.c b/VTK/Wrapping/Tools/vtkWrapPythonType.c
99cfd9f
index 744cb1b9d3..0a1375e541 100644
99cfd9f
--- a/VTK/Wrapping/Tools/vtkWrapPythonType.c
99cfd9f
+++ b/VTK/Wrapping/Tools/vtkWrapPythonType.c
99cfd9f
@@ -709,7 +709,7 @@ void vtkWrapPython_GenerateSpecialType(
99cfd9f
     "  sizeof(PyVTKSpecialObject), // tp_basicsize\n"
99cfd9f
     "  0, // tp_itemsize\n"
99cfd9f
     "  Py%s_Delete, // tp_dealloc\n"
99cfd9f
-    "  nullptr, // tp_print\n"
99cfd9f
+    "  0, // tp_vectorcall_offset\n"
99cfd9f
     "  nullptr, // tp_getattr\n"
99cfd9f
     "  nullptr, // tp_setattr\n"
99cfd9f
     "  nullptr, // tp_compare\n"
99cfd9f
-- 
99cfd9f
2.21.0
99cfd9f