1 From 257b9d7b18d5f3db3fe099dc18f230e23f7dfbab Mon Sep 17 00:00:00 2001
2 From: David Gobbi <david.gobbi@gmail.com>
3 Date: Tue, 20 Aug 2019 17:02:24 -0600
4 Subject: [PATCH] Compatibility for Python 3.8
6 The PyTypeObject struct was modified in Python 3.8, this change is
7 required to avoid compile errors.
9 .../PythonInterpreter/vtkPythonStdStreamCaptureHelper.h | 6 ++++++
10 Wrapping/PythonCore/PyVTKMethodDescriptor.cxx | 2 +-
11 Wrapping/PythonCore/PyVTKNamespace.cxx | 2 +-
12 Wrapping/PythonCore/PyVTKReference.cxx | 8 ++++----
13 Wrapping/PythonCore/PyVTKTemplate.cxx | 2 +-
14 Wrapping/PythonCore/vtkPythonCompatibility.h | 8 +++++++-
15 Wrapping/Tools/vtkWrapPythonClass.c | 2 +-
16 Wrapping/Tools/vtkWrapPythonEnum.c | 2 +-
17 Wrapping/Tools/vtkWrapPythonType.c | 2 +-
18 9 files changed, 23 insertions(+), 11 deletions(-)
20 diff --git a/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h b/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h
21 index b1c12c83de..14ccfbe928 100644
22 --- a/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h
23 +++ b/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h
24 @@ -140,6 +140,12 @@ static PyTypeObject vtkPythonStdStreamCaptureHelperType = {
25 #if PY_VERSION_HEX >= 0x03040000
28 +#if PY_VERSION_HEX >= 0x03080000
30 +#if PY_VERSION_HEX < 0x03090000
36 static PyObject* vtkWrite(PyObject* self, PyObject* args)
37 diff --git a/Wrapping/PythonCore/PyVTKMethodDescriptor.cxx b/Wrapping/PythonCore/PyVTKMethodDescriptor.cxx
38 index 2b0d443537..3840038498 100644
39 --- a/Wrapping/PythonCore/PyVTKMethodDescriptor.cxx
40 +++ b/Wrapping/PythonCore/PyVTKMethodDescriptor.cxx
41 @@ -186,7 +186,7 @@ PyTypeObject PyVTKMethodDescriptor_Type = {
42 sizeof(PyMethodDescrObject), // tp_basicsize
44 PyVTKMethodDescriptor_Delete, // tp_dealloc
45 - nullptr, // tp_print
46 + 0, // tp_vectorcall_offset
47 nullptr, // tp_getattr
48 nullptr, // tp_setattr
49 nullptr, // tp_compare
50 diff --git a/Wrapping/PythonCore/PyVTKNamespace.cxx b/Wrapping/PythonCore/PyVTKNamespace.cxx
51 index 71ee2a3516..5cf5bfbe6b 100644
52 --- a/Wrapping/PythonCore/PyVTKNamespace.cxx
53 +++ b/Wrapping/PythonCore/PyVTKNamespace.cxx
54 @@ -49,7 +49,7 @@ PyTypeObject PyVTKNamespace_Type = {
57 PyVTKNamespace_Delete, // tp_dealloc
58 - nullptr, // tp_print
59 + 0, // tp_vectorcall_offset
60 nullptr, // tp_getattr
61 nullptr, // tp_setattr
62 nullptr, // tp_compare
63 diff --git a/Wrapping/PythonCore/PyVTKReference.cxx b/Wrapping/PythonCore/PyVTKReference.cxx
64 index 943ac71080..b7104091c0 100644
65 --- a/Wrapping/PythonCore/PyVTKReference.cxx
66 +++ b/Wrapping/PythonCore/PyVTKReference.cxx
67 @@ -1010,7 +1010,7 @@ PyTypeObject PyVTKReference_Type = {
68 sizeof(PyVTKReference), // tp_basicsize
70 PyVTKReference_Delete, // tp_dealloc
71 - nullptr, // tp_print
72 + 0, // tp_vectorcall_offset
73 nullptr, // tp_getattr
74 nullptr, // tp_setattr
75 nullptr, // tp_compare
76 @@ -1067,7 +1067,7 @@ PyTypeObject PyVTKNumberReference_Type = {
77 sizeof(PyVTKReference), // tp_basicsize
79 PyVTKReference_Delete, // tp_dealloc
80 - nullptr, // tp_print
81 + 0, // tp_vectorcall_offset
82 nullptr, // tp_getattr
83 nullptr, // tp_setattr
84 nullptr, // tp_compare
85 @@ -1124,7 +1124,7 @@ PyTypeObject PyVTKStringReference_Type = {
86 sizeof(PyVTKReference), // tp_basicsize
88 PyVTKReference_Delete, // tp_dealloc
89 - nullptr, // tp_print
90 + 0, // tp_vectorcall_offset
91 nullptr, // tp_getattr
92 nullptr, // tp_setattr
93 nullptr, // tp_compare
94 @@ -1181,7 +1181,7 @@ PyTypeObject PyVTKTupleReference_Type = {
95 sizeof(PyVTKReference), // tp_basicsize
97 PyVTKReference_Delete, // tp_dealloc
98 - nullptr, // tp_print
99 + 0, // tp_vectorcall_offset
100 nullptr, // tp_getattr
101 nullptr, // tp_setattr
102 nullptr, // tp_compare
103 diff --git a/Wrapping/PythonCore/PyVTKTemplate.cxx b/Wrapping/PythonCore/PyVTKTemplate.cxx
104 index be200985b3..340fe7953b 100644
105 --- a/Wrapping/PythonCore/PyVTKTemplate.cxx
106 +++ b/Wrapping/PythonCore/PyVTKTemplate.cxx
107 @@ -268,7 +268,7 @@ PyTypeObject PyVTKTemplate_Type = {
110 nullptr, // tp_dealloc
111 - nullptr, // tp_print
112 + 0, // tp_vectorcall_offset
113 nullptr, // tp_getattr
114 nullptr, // tp_setattr
115 nullptr, // tp_compare
116 diff --git a/Wrapping/PythonCore/vtkPythonCompatibility.h b/Wrapping/PythonCore/vtkPythonCompatibility.h
117 index 4a767844a6..be208faeef 100644
118 --- a/Wrapping/PythonCore/vtkPythonCompatibility.h
119 +++ b/Wrapping/PythonCore/vtkPythonCompatibility.h
123 // PyTypeObject compatibility
124 -#if PY_VERSION_HEX >= 0x03040000
125 +#if PY_VERSION_HEX >= 0x03090000
126 +#define VTK_WRAP_PYTHON_SUPPRESS_UNINITIALIZED \
128 +#elif PY_VERSION_HEX >= 0x03080000
129 +#define VTK_WRAP_PYTHON_SUPPRESS_UNINITIALIZED \
131 +#elif PY_VERSION_HEX >= 0x03040000
132 #define VTK_WRAP_PYTHON_SUPPRESS_UNINITIALIZED \
135 diff --git a/Wrapping/Tools/vtkWrapPythonClass.c b/Wrapping/Tools/vtkWrapPythonClass.c
136 index b1e45f8e80..4d558ea081 100644
137 --- a/Wrapping/Tools/vtkWrapPythonClass.c
138 +++ b/Wrapping/Tools/vtkWrapPythonClass.c
139 @@ -521,7 +521,7 @@ void vtkWrapPython_GenerateObjectType(
140 " sizeof(PyVTKObject), // tp_basicsize\n"
141 " 0, // tp_itemsize\n"
142 " PyVTKObject_Delete, // tp_dealloc\n"
143 - " nullptr, // tp_print\n"
144 + " 0, // tp_vectorcall_offset\n"
145 " nullptr, // tp_getattr\n"
146 " nullptr, // tp_setattr\n"
147 " nullptr, // tp_compare\n"
148 diff --git a/Wrapping/Tools/vtkWrapPythonEnum.c b/Wrapping/Tools/vtkWrapPythonEnum.c
149 index b933702242..1249362854 100644
150 --- a/Wrapping/Tools/vtkWrapPythonEnum.c
151 +++ b/Wrapping/Tools/vtkWrapPythonEnum.c
152 @@ -145,7 +145,7 @@ void vtkWrapPython_GenerateEnumType(
153 " sizeof(PyIntObject), // tp_basicsize\n"
154 " 0, // tp_itemsize\n"
155 " nullptr, // tp_dealloc\n"
156 - " nullptr, // tp_print\n"
157 + " 0, // tp_vectorcall_offset\n"
158 " nullptr, // tp_getattr\n"
159 " nullptr, // tp_setattr\n"
160 " nullptr, // tp_compare\n"
161 diff --git a/Wrapping/Tools/vtkWrapPythonType.c b/Wrapping/Tools/vtkWrapPythonType.c
162 index 744cb1b9d3..0a1375e541 100644
163 --- a/Wrapping/Tools/vtkWrapPythonType.c
164 +++ b/Wrapping/Tools/vtkWrapPythonType.c
165 @@ -709,7 +709,7 @@ void vtkWrapPython_GenerateSpecialType(
166 " sizeof(PyVTKSpecialObject), // tp_basicsize\n"
167 " 0, // tp_itemsize\n"
168 " Py%s_Delete, // tp_dealloc\n"
169 - " nullptr, // tp_print\n"
170 + " 0, // tp_vectorcall_offset\n"
171 " nullptr, // tp_getattr\n"
172 " nullptr, // tp_setattr\n"
173 " nullptr, // tp_compare\n"