summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorPetr Viktorin <encukou@gmail.com>2019-06-02 21:52:20 (GMT)
committerGitHub <noreply@github.com>2019-06-02 21:52:20 (GMT)
commitfb9423fd0a85f06affb8c3a8f25dd598a649aa42 (patch)
treee44d7ac1b3483da0f95a9f95e6907c1d5036a242 /Modules/_testcapimodule.c
parente1179a5096fb12297ececd7a1c79969aa5747e28 (diff)
downloadcpython-fb9423fd0a85f06affb8c3a8f25dd598a649aa42.zip
cpython-fb9423fd0a85f06affb8c3a8f25dd598a649aa42.tar.gz
cpython-fb9423fd0a85f06affb8c3a8f25dd598a649aa42.tar.bz2
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.
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index bf20e81..eed34c9 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -5854,7 +5854,7 @@ MethodDescriptor_vectorcall(PyObject *callable, PyObject *const *args,
static PyObject *
MethodDescriptor_new(PyTypeObject* type, PyObject* args, PyObject *kw)
{
- MethodDescriptorObject *op = PyObject_New(MethodDescriptorObject, type);
+ MethodDescriptorObject *op = type->tp_alloc(type, 0);
op->vectorcall = MethodDescriptor_vectorcall;
return (PyObject *)op;
}