bpo-39245: Switch to public API for Vectorcall (GH-18460)

The bulk of this patch was generated automatically with:

    for name in \
        PyObject_Vectorcall \
        Py_TPFLAGS_HAVE_VECTORCALL \
        PyObject_VectorcallMethod \
        PyVectorcall_Function \
        PyObject_CallOneArg \
        PyObject_CallMethodNoArgs \
        PyObject_CallMethodOneArg \
    ;
    do
        echo $name
        git grep -lwz _$name | xargs -0 sed -i "s/\b_$name\b/$name/g"
    done

    old=_PyObject_FastCallDict
    new=PyObject_VectorcallDict
    git grep -lwz $old | xargs -0 sed -i "s/\b$old\b/$new/g"

and then cleaned up:

- Revert changes to in docs & news
- Revert changes to backcompat defines in headers
- Nudge misaligned comments
This commit is contained in:
Petr Viktorin 2020-02-11 17:46:57 +01:00 committed by GitHub
parent f3e7ea5b8c
commit ffd9753a94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 194 additions and 194 deletions

View file

@ -1465,7 +1465,7 @@ static PyObject*
call_unbound_noarg(int unbound, PyObject *func, PyObject *self)
{
if (unbound) {
return _PyObject_CallOneArg(func, self);
return PyObject_CallOneArg(func, self);
}
else {
return _PyObject_CallNoArg(func);
@ -3665,7 +3665,7 @@ PyTypeObject PyType_Type = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TYPE_SUBCLASS |
_Py_TPFLAGS_HAVE_VECTORCALL, /* tp_flags */
Py_TPFLAGS_HAVE_VECTORCALL, /* tp_flags */
type_doc, /* tp_doc */
(traverseproc)type_traverse, /* tp_traverse */
(inquiry)type_clear, /* tp_clear */
@ -5196,17 +5196,17 @@ inherit_slots(PyTypeObject *type, PyTypeObject *base)
/* tp_hash see tp_richcompare */
{
/* Always inherit tp_vectorcall_offset to support PyVectorcall_Call().
* If _Py_TPFLAGS_HAVE_VECTORCALL is not inherited, then vectorcall
* If Py_TPFLAGS_HAVE_VECTORCALL is not inherited, then vectorcall
* won't be used automatically. */
COPYSLOT(tp_vectorcall_offset);
/* Inherit _Py_TPFLAGS_HAVE_VECTORCALL for non-heap types
/* Inherit Py_TPFLAGS_HAVE_VECTORCALL for non-heap types
* if tp_call is not overridden */
if (!type->tp_call &&
(base->tp_flags & _Py_TPFLAGS_HAVE_VECTORCALL) &&
(base->tp_flags & Py_TPFLAGS_HAVE_VECTORCALL) &&
!(type->tp_flags & Py_TPFLAGS_HEAPTYPE))
{
type->tp_flags |= _Py_TPFLAGS_HAVE_VECTORCALL;
type->tp_flags |= Py_TPFLAGS_HAVE_VECTORCALL;
}
COPYSLOT(tp_call);
}
@ -5282,14 +5282,14 @@ PyType_Ready(PyTypeObject *type)
/* Consistency checks for PEP 590:
* - Py_TPFLAGS_METHOD_DESCRIPTOR requires tp_descr_get
* - _Py_TPFLAGS_HAVE_VECTORCALL requires tp_call and
* - Py_TPFLAGS_HAVE_VECTORCALL requires tp_call and
* tp_vectorcall_offset > 0
* To avoid mistakes, we require this before inheriting.
*/
if (type->tp_flags & Py_TPFLAGS_METHOD_DESCRIPTOR) {
_PyObject_ASSERT((PyObject *)type, type->tp_descr_get != NULL);
}
if (type->tp_flags & _Py_TPFLAGS_HAVE_VECTORCALL) {
if (type->tp_flags & Py_TPFLAGS_HAVE_VECTORCALL) {
_PyObject_ASSERT((PyObject *)type, type->tp_vectorcall_offset > 0);
_PyObject_ASSERT((PyObject *)type, type->tp_call != NULL);
}
@ -6614,7 +6614,7 @@ call_attribute(PyObject *self, PyObject *attr, PyObject *name)
else
attr = descr;
}
res = _PyObject_CallOneArg(attr, name);
res = PyObject_CallOneArg(attr, name);
Py_XDECREF(descr);
return res;
}
@ -7575,7 +7575,7 @@ init_subclass(PyTypeObject *type, PyObject *kwds)
}
result = _PyObject_FastCallDict(func, NULL, 0, kwds);
result = PyObject_VectorcallDict(func, NULL, 0, kwds);
Py_DECREF(func);
if (result == NULL) {
return -1;