Skip to content

Commit 4c54801

Browse files
authored
Fix _PyObject_FastCall for Python 3.13 (#17502)
`_PyObject_FastCall` will be removed in 3.13. It can safely replaced by `PyObject_Vectorcall` (available since `3.9`) / `_PyObject_Vectorcall` (available since `3.8`). python/cpython#106023 (comment) https://peps.python.org/pep-0590/ Fixes ```cpp /home/runner/work/mypy/mypy/mypyc/lib-rt/pythonsupport.h: In function ‘update_bases’: (diff) /home/runner/work/mypy/mypy/mypyc/lib-rt/pythonsupport.h:62:20: error: implicit declaration of function ‘_PyObject_FastCall’; did you mean ‘PyObject_Call’? [-Werror=implicit-function-declaration] (diff) 62 | new_base = _PyObject_FastCall(meth, stack, 1); (diff) /home/runner/work/mypy/mypy/mypyc/lib-rt/pythonsupport.h:62:18: error: assignment to ‘PyObject *’ {aka ‘struct _object *’} from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion] (diff) 62 | new_base = _PyObject_FastCall(meth, stack, 1); (diff) | ^ (diff) /home/runner/work/mypy/mypy/mypyc/lib-rt/pythonsupport.h: In function ‘init_subclass’: (diff) /home/runner/work/mypy/mypy/mypyc/lib-rt/pythonsupport.h:111:11: error: assignment to ‘PyObject *’ {aka ‘struct _object *’} from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion] (diff) 111 | super = _PyObject_FastCall((PyObject *)&PySuper_Type, args, 2); (diff) | ^ (diff) ```
1 parent 6d45f3c commit 4c54801

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mypyc/lib-rt/pythonsupport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ update_bases(PyObject *bases)
5959
}
6060
continue;
6161
}
62-
new_base = _PyObject_FastCall(meth, stack, 1);
62+
new_base = _PyObject_Vectorcall(meth, stack, 1, NULL);
6363
Py_DECREF(meth);
6464
if (!new_base) {
6565
goto error;
@@ -108,7 +108,7 @@ init_subclass(PyTypeObject *type, PyObject *kwds)
108108
PyObject *super, *func, *result;
109109
PyObject *args[2] = {(PyObject *)type, (PyObject *)type};
110110

111-
super = _PyObject_FastCall((PyObject *)&PySuper_Type, args, 2);
111+
super = _PyObject_Vectorcall((PyObject *)&PySuper_Type, args, 2, NULL);
112112
if (super == NULL) {
113113
return -1;
114114
}

0 commit comments

Comments
 (0)