From 00e84cfcc5a0812503b431238fc26c349b0d714f Mon Sep 17 00:00:00 2001
From: David Gobbi <david.gobbi@gmail.com>
Date: Tue, 20 Aug 2019 17:02:24 -0600
Subject: [PATCH] Compatibility for Python 3.8
The PyTypeObject struct was modified in Python 3.8, this change is
required to avoid compile errors.
---
Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h | 6 ++++++
Wrapping/PythonCore/PyVTKMethodDescriptor.cxx | 2 +-
Wrapping/PythonCore/PyVTKNamespace.cxx | 2 +-
Wrapping/PythonCore/PyVTKReference.cxx | 8 ++++----
Wrapping/PythonCore/PyVTKTemplate.cxx | 2 +-
Wrapping/PythonCore/vtkPythonCompatibility.h | 8 +++++++-
Wrapping/Tools/vtkWrapPythonClass.c | 2 +-
Wrapping/Tools/vtkWrapPythonEnum.c | 2 +-
Wrapping/Tools/vtkWrapPythonType.c | 2 +-
9 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h b/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h
index b1c12c8..14ccfbe 100644
|
|
static PyTypeObject vtkPythonStdStreamCaptureHelperType = { |
140 | 140 | #if PY_VERSION_HEX >= 0x03040000 |
141 | 141 | 0, // tp_finalize |
142 | 142 | #endif |
| 143 | #if PY_VERSION_HEX >= 0x03080000 |
| 144 | 0, // tp_vectorcall |
| 145 | #if PY_VERSION_HEX < 0x03090000 |
| 146 | 0, // tp_print |
| 147 | #endif |
| 148 | #endif |
143 | 149 | }; |
144 | 150 | |
145 | 151 | static PyObject* vtkWrite(PyObject* self, PyObject* args) |
diff --git a/Wrapping/PythonCore/PyVTKMethodDescriptor.cxx b/Wrapping/PythonCore/PyVTKMethodDescriptor.cxx
index 2b0d443..3840038 100644
|
|
PyTypeObject PyVTKMethodDescriptor_Type = { |
186 | 186 | sizeof(PyMethodDescrObject), // tp_basicsize |
187 | 187 | 0, // tp_itemsize |
188 | 188 | PyVTKMethodDescriptor_Delete, // tp_dealloc |
189 | | nullptr, // tp_print |
| 189 | 0, // tp_vectorcall_offset |
190 | 190 | nullptr, // tp_getattr |
191 | 191 | nullptr, // tp_setattr |
192 | 192 | nullptr, // tp_compare |
diff --git a/Wrapping/PythonCore/PyVTKNamespace.cxx b/Wrapping/PythonCore/PyVTKNamespace.cxx
index 71ee2a3..5cf5bfb 100644
|
|
PyTypeObject PyVTKNamespace_Type = { |
49 | 49 | 0, // tp_basicsize |
50 | 50 | 0, // tp_itemsize |
51 | 51 | PyVTKNamespace_Delete, // tp_dealloc |
52 | | nullptr, // tp_print |
| 52 | 0, // tp_vectorcall_offset |
53 | 53 | nullptr, // tp_getattr |
54 | 54 | nullptr, // tp_setattr |
55 | 55 | nullptr, // tp_compare |
diff --git a/Wrapping/PythonCore/PyVTKReference.cxx b/Wrapping/PythonCore/PyVTKReference.cxx
index 943ac71..b710409 100644
|
|
PyTypeObject PyVTKReference_Type = { |
1010 | 1010 | sizeof(PyVTKReference), // tp_basicsize |
1011 | 1011 | 0, // tp_itemsize |
1012 | 1012 | PyVTKReference_Delete, // tp_dealloc |
1013 | | nullptr, // tp_print |
| 1013 | 0, // tp_vectorcall_offset |
1014 | 1014 | nullptr, // tp_getattr |
1015 | 1015 | nullptr, // tp_setattr |
1016 | 1016 | nullptr, // tp_compare |
… |
… |
PyTypeObject PyVTKNumberReference_Type = { |
1067 | 1067 | sizeof(PyVTKReference), // tp_basicsize |
1068 | 1068 | 0, // tp_itemsize |
1069 | 1069 | PyVTKReference_Delete, // tp_dealloc |
1070 | | nullptr, // tp_print |
| 1070 | 0, // tp_vectorcall_offset |
1071 | 1071 | nullptr, // tp_getattr |
1072 | 1072 | nullptr, // tp_setattr |
1073 | 1073 | nullptr, // tp_compare |
… |
… |
PyTypeObject PyVTKStringReference_Type = { |
1124 | 1124 | sizeof(PyVTKReference), // tp_basicsize |
1125 | 1125 | 0, // tp_itemsize |
1126 | 1126 | PyVTKReference_Delete, // tp_dealloc |
1127 | | nullptr, // tp_print |
| 1127 | 0, // tp_vectorcall_offset |
1128 | 1128 | nullptr, // tp_getattr |
1129 | 1129 | nullptr, // tp_setattr |
1130 | 1130 | nullptr, // tp_compare |
… |
… |
PyTypeObject PyVTKTupleReference_Type = { |
1181 | 1181 | sizeof(PyVTKReference), // tp_basicsize |
1182 | 1182 | 0, // tp_itemsize |
1183 | 1183 | PyVTKReference_Delete, // tp_dealloc |
1184 | | nullptr, // tp_print |
| 1184 | 0, // tp_vectorcall_offset |
1185 | 1185 | nullptr, // tp_getattr |
1186 | 1186 | nullptr, // tp_setattr |
1187 | 1187 | nullptr, // tp_compare |
diff --git a/Wrapping/PythonCore/PyVTKTemplate.cxx b/Wrapping/PythonCore/PyVTKTemplate.cxx
index be20098..340fe79 100644
|
|
PyTypeObject PyVTKTemplate_Type = { |
268 | 268 | 0, // tp_basicsize |
269 | 269 | 0, // tp_itemsize |
270 | 270 | nullptr, // tp_dealloc |
271 | | nullptr, // tp_print |
| 271 | 0, // tp_vectorcall_offset |
272 | 272 | nullptr, // tp_getattr |
273 | 273 | nullptr, // tp_setattr |
274 | 274 | nullptr, // tp_compare |
diff --git a/Wrapping/PythonCore/vtkPythonCompatibility.h b/Wrapping/PythonCore/vtkPythonCompatibility.h
index 4a76784..be208fa 100644
|
|
|
64 | 64 | #endif |
65 | 65 | |
66 | 66 | // PyTypeObject compatibility |
67 | | #if PY_VERSION_HEX >= 0x03040000 |
| 67 | #if PY_VERSION_HEX >= 0x03090000 |
| 68 | #define VTK_WRAP_PYTHON_SUPPRESS_UNINITIALIZED \ |
| 69 | 0, 0, 0, 0, |
| 70 | #elif PY_VERSION_HEX >= 0x03080000 |
| 71 | #define VTK_WRAP_PYTHON_SUPPRESS_UNINITIALIZED \ |
| 72 | 0, 0, 0, 0, 0, |
| 73 | #elif PY_VERSION_HEX >= 0x03040000 |
68 | 74 | #define VTK_WRAP_PYTHON_SUPPRESS_UNINITIALIZED \ |
69 | 75 | 0, 0, 0, |
70 | 76 | #else |
diff --git a/Wrapping/Tools/vtkWrapPythonClass.c b/Wrapping/Tools/vtkWrapPythonClass.c
index b1e45f8..4d558ea 100644
|
|
void vtkWrapPython_GenerateObjectType( |
521 | 521 | " sizeof(PyVTKObject), // tp_basicsize\n" |
522 | 522 | " 0, // tp_itemsize\n" |
523 | 523 | " PyVTKObject_Delete, // tp_dealloc\n" |
524 | | " nullptr, // tp_print\n" |
| 524 | " 0, // tp_vectorcall_offset\n" |
525 | 525 | " nullptr, // tp_getattr\n" |
526 | 526 | " nullptr, // tp_setattr\n" |
527 | 527 | " nullptr, // tp_compare\n" |
diff --git a/Wrapping/Tools/vtkWrapPythonEnum.c b/Wrapping/Tools/vtkWrapPythonEnum.c
index b933702..1249362 100644
|
|
void vtkWrapPython_GenerateEnumType( |
145 | 145 | " sizeof(PyIntObject), // tp_basicsize\n" |
146 | 146 | " 0, // tp_itemsize\n" |
147 | 147 | " nullptr, // tp_dealloc\n" |
148 | | " nullptr, // tp_print\n" |
| 148 | " 0, // tp_vectorcall_offset\n" |
149 | 149 | " nullptr, // tp_getattr\n" |
150 | 150 | " nullptr, // tp_setattr\n" |
151 | 151 | " nullptr, // tp_compare\n" |
diff --git a/Wrapping/Tools/vtkWrapPythonType.c b/Wrapping/Tools/vtkWrapPythonType.c
index 744cb1b..0a1375e 100644
|
|
void vtkWrapPython_GenerateSpecialType( |
709 | 709 | " sizeof(PyVTKSpecialObject), // tp_basicsize\n" |
710 | 710 | " 0, // tp_itemsize\n" |
711 | 711 | " Py%s_Delete, // tp_dealloc\n" |
712 | | " nullptr, // tp_print\n" |
| 712 | " 0, // tp_vectorcall_offset\n" |
713 | 713 | " nullptr, // tp_getattr\n" |
714 | 714 | " nullptr, // tp_setattr\n" |
715 | 715 | " nullptr, // tp_compare\n" |