bpo-36974: inherit the vectorcall protocol (GH-13498)

This commit is contained in:
Jeroen Demeyer 2019-05-30 12:43:19 +02:00 committed by Petr Viktorin
parent 0f39c2b191
commit 735e8afa9e
3 changed files with 104 additions and 2 deletions

View file

@ -5147,6 +5147,17 @@ inherit_slots(PyTypeObject *type, PyTypeObject *base)
COPYSLOT(tp_repr);
/* tp_hash see tp_richcompare */
COPYSLOT(tp_call);
/* Inherit tp_vectorcall_offset and _Py_TPFLAGS_HAVE_VECTORCALL if tp_call
* was inherited, but only for extension types */
if ((base->tp_flags & _Py_TPFLAGS_HAVE_VECTORCALL) &&
!(type->tp_flags & _Py_TPFLAGS_HAVE_VECTORCALL) &&
!(type->tp_flags & Py_TPFLAGS_HEAPTYPE) &&
base->tp_call &&
type->tp_call == base->tp_call)
{
type->tp_vectorcall_offset = base->tp_vectorcall_offset;
type->tp_flags |= _Py_TPFLAGS_HAVE_VECTORCALL;
}
COPYSLOT(tp_str);
{
/* Copy comparison-related slots only when