]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-36974: Make tp_call=PyVectorcall_Call work for inherited types (GH-13699)
authorPetr Viktorin <encukou@gmail.com>
Sun, 2 Jun 2019 21:52:20 +0000 (23:52 +0200)
committerGitHub <noreply@github.com>
Sun, 2 Jun 2019 21:52:20 +0000 (23:52 +0200)
commitfb9423fd0a85f06affb8c3a8f25dd598a649aa42
treee44d7ac1b3483da0f95a9f95e6907c1d5036a242
parente1179a5096fb12297ececd7a1c79969aa5747e28
bpo-36974: Make tp_call=PyVectorcall_Call work for inherited types (GH-13699)

When inheriting a heap subclass from a vectorcall class that sets
`.tp_call=PyVectorcall_Call` (as recommended in PEP 590), the subclass does
not inherit `_Py_TPFLAGS_HAVE_VECTORCALL`, and thus `PyVectorcall_Call` does
not work for it.

This attempts to solve the issue by:
* always inheriting `tp_vectorcall_offset` unless `tp_call` is overridden
  in the subclass
* inheriting _Py_TPFLAGS_HAVE_VECTORCALL for static types, unless `tp_call`
  is overridden
* making `PyVectorcall_Call` ignore `_Py_TPFLAGS_HAVE_VECTORCALL`

This means it'll be ever more important to only call `PyVectorcall_Call`
on classes that support vectorcall. In `PyVectorcall_Call`'s intended role
as `tp_call` filler, that's not a problem.
Lib/test/test_capi.py
Modules/_testcapimodule.c
Objects/call.c
Objects/typeobject.c