[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

@ -4145,7 +4145,11 @@ public:
printSlot(f, getSlot(n, "feature:python:tp_basicsize", tp_basicsize), "tp_basicsize");
printSlot(f, getSlot(n, "feature:python:tp_itemsize"), "tp_itemsize");
printSlot(f, getSlot(n, "feature:python:tp_dealloc", tp_dealloc_bad), "tp_dealloc", "destructor");
Printv(f, "#if PY_VERSION_HEX < 0x030800b4\n", NIL);
printSlot(f, getSlot(n, "feature:python:tp_print"), "tp_print", "printfunc");
Printv(f, "#else\n", NIL);
printSlot(f, getSlot(n, "feature:python:tp_vectorcall_offset"), "tp_vectorcall_offset", "Py_ssize_t");
Printv(f, "#endif\n", NIL);
printSlot(f, getSlot(n, "feature:python:tp_getattr"), "tp_getattr", "getattrfunc");
printSlot(f, getSlot(n, "feature:python:tp_setattr"), "tp_setattr", "setattrfunc");
Printv(f, "#if PY_VERSION_HEX >= 0x03000000\n", NIL);