diff options
author | Jeroen Demeyer <J.Demeyer@UGent.be> | 2019-05-30 10:43:19 (GMT) |
---|---|---|
committer | Petr Viktorin <encukou@gmail.com> | 2019-05-30 10:43:19 (GMT) |
commit | 735e8afa9ee942367b5d0807633a2b9f662cbdbf (patch) | |
tree | 5ec70a74c5399a91fb78183139ca67d3950ba4d6 /Objects | |
parent | 0f39c2b1919727904f4fac2d79cb41dc6bfe41fe (diff) | |
download | cpython-735e8afa9ee942367b5d0807633a2b9f662cbdbf.zip cpython-735e8afa9ee942367b5d0807633a2b9f662cbdbf.tar.gz cpython-735e8afa9ee942367b5d0807633a2b9f662cbdbf.tar.bz2 |
bpo-36974: inherit the vectorcall protocol (GH-13498)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 071ff27..ac5a686 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -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 |