• Petr Viktorin's avatar
    bpo-36974: Make tp_call=PyVectorcall_Call work for inherited types (GH-13699) · fb9423fd
    Petr Viktorin authored
    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.
    fb9423fd
call.c 36.8 KB