[Python] Replace tp_print with tp_vectorcall_offset slot for Python 3.8

The tp_print slot is no longer supported and replaced with tp_vectorcall_offset.
The (printfunc) cast that we used caused problems on PyPy.

Fixes #2262
This commit is contained in:
Kris Thielemans 2022-04-21 12:28:54 +01:00
commit f5934b099b
3 changed files with 29 additions and 5 deletions

View file

@ -211,7 +211,11 @@ SwigPyStaticVar_Type(void) {
sizeof(PyGetSetDescrObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)SwigPyStaticVar_dealloc, /* tp_dealloc */
0, /* tp_print */
#if PY_VERSION_HEX < 0x030800b4
(printfunc)0, /*tp_print*/
#else
(Py_ssize_t)0, /*tp_vectorcall_offset*/
#endif
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
@ -295,7 +299,11 @@ SwigPyObjectType(void) {
PyType_Type.tp_basicsize, /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
#if PY_VERSION_HEX < 0x030800b4
(printfunc)0, /*tp_print*/
#else
(Py_ssize_t)0, /*tp_vectorcall_offset*/
#endif
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */