diff options
author | Petr Viktorin <encukou@gmail.com> | 2020-02-11 17:46:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-11 17:46:57 +0100 |
commit | ffd9753a944916ced659b2c77aebe66a6c9fbab5 (patch) | |
tree | f3469bdca81c102afa811a39dd3eaa9643287e93 /Objects | |
parent | f3e7ea5b8c220cd63101e419d529c8563f9c6115 (diff) | |
download | cpython-git-ffd9753a944916ced659b2c77aebe66a6c9fbab5.tar.gz |
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
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/abstract.c | 8 | ||||
-rw-r--r-- | Objects/bytearrayobject.c | 4 | ||||
-rw-r--r-- | Objects/bytesobject.c | 2 | ||||
-rw-r--r-- | Objects/call.c | 14 | ||||
-rw-r--r-- | Objects/classobject.c | 2 | ||||
-rw-r--r-- | Objects/descrobject.c | 8 | ||||
-rw-r--r-- | Objects/dictobject.c | 2 | ||||
-rw-r--r-- | Objects/fileobject.c | 2 | ||||
-rw-r--r-- | Objects/floatobject.c | 2 | ||||
-rw-r--r-- | Objects/funcobject.c | 2 | ||||
-rw-r--r-- | Objects/genobject.c | 8 | ||||
-rw-r--r-- | Objects/listobject.c | 2 | ||||
-rw-r--r-- | Objects/longobject.c | 2 | ||||
-rw-r--r-- | Objects/memoryobject.c | 4 | ||||
-rw-r--r-- | Objects/methodobject.c | 2 | ||||
-rw-r--r-- | Objects/moduleobject.c | 2 | ||||
-rw-r--r-- | Objects/typeobject.c | 20 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 8 | ||||
-rw-r--r-- | Objects/weakrefobject.c | 2 |
19 files changed, 48 insertions, 48 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 7ab58a8bd5..f0e01f7691 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -179,7 +179,7 @@ PyObject_GetItem(PyObject *o, PyObject *key) return NULL; } if (meth) { - result = _PyObject_CallOneArg(meth, key); + result = PyObject_CallOneArg(meth, key); Py_DECREF(meth); return result; } @@ -780,7 +780,7 @@ PyObject_Format(PyObject *obj, PyObject *format_spec) } /* And call it. */ - result = _PyObject_CallOneArg(meth, format_spec); + result = PyObject_CallOneArg(meth, format_spec); Py_DECREF(meth); if (result && !PyUnicode_Check(result)) { @@ -2502,7 +2502,7 @@ object_recursive_isinstance(PyThreadState *tstate, PyObject *inst, PyObject *cls return -1; } - PyObject *res = _PyObject_CallOneArg(checker, inst); + PyObject *res = PyObject_CallOneArg(checker, inst); _Py_LeaveRecursiveCall(tstate); Py_DECREF(checker); @@ -2588,7 +2588,7 @@ object_issubclass(PyThreadState *tstate, PyObject *derived, PyObject *cls) Py_DECREF(checker); return ok; } - PyObject *res = _PyObject_CallOneArg(checker, derived); + PyObject *res = PyObject_CallOneArg(checker, derived); _Py_LeaveRecursiveCall(tstate); Py_DECREF(checker); if (res != NULL) { diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index b2808c05b4..a3fc35ca4d 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -89,7 +89,7 @@ _canresize(PyByteArrayObject *self) PyObject * PyByteArray_FromObject(PyObject *input) { - return _PyObject_CallOneArg((PyObject *)&PyByteArray_Type, input); + return PyObject_CallOneArg((PyObject *)&PyByteArray_Type, input); } static PyObject * @@ -2015,7 +2015,7 @@ bytearray_fromhex_impl(PyTypeObject *type, PyObject *string) { PyObject *result = _PyBytes_FromHex(string, type == &PyByteArray_Type); if (type != &PyByteArray_Type && result != NULL) { - Py_SETREF(result, _PyObject_CallOneArg((PyObject *)type, result)); + Py_SETREF(result, PyObject_CallOneArg((PyObject *)type, result)); } return result; } diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index e139bed71b..df3eddae6a 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2259,7 +2259,7 @@ bytes_fromhex_impl(PyTypeObject *type, PyObject *string) { PyObject *result = _PyBytes_FromHex(string, 0); if (type != &PyBytes_Type && result != NULL) { - Py_SETREF(result, _PyObject_CallOneArg((PyObject *)type, result)); + Py_SETREF(result, PyObject_CallOneArg((PyObject *)type, result)); } return result; } diff --git a/Objects/call.c b/Objects/call.c index d1d50b647f..37d079d169 100644 --- a/Objects/call.c +++ b/Objects/call.c @@ -95,7 +95,7 @@ _PyObject_FastCallDictTstate(PyThreadState *tstate, PyObject *callable, { assert(callable != NULL); - /* _PyObject_FastCallDict() must not be called with an exception set, + /* PyObject_VectorcallDict() must not be called with an exception set, because it can clear it (directly or indirectly) and so the caller loses its exception */ assert(!_PyErr_Occurred(tstate)); @@ -105,7 +105,7 @@ _PyObject_FastCallDictTstate(PyThreadState *tstate, PyObject *callable, assert(nargs == 0 || args != NULL); assert(kwargs == NULL || PyDict_Check(kwargs)); - vectorcallfunc func = _PyVectorcall_Function(callable); + vectorcallfunc func = PyVectorcall_Function(callable); if (func == NULL) { /* Use tp_call instead */ return _PyObject_MakeTpCall(tstate, callable, args, nargs, kwargs); @@ -133,7 +133,7 @@ _PyObject_FastCallDictTstate(PyThreadState *tstate, PyObject *callable, PyObject * -_PyObject_FastCallDict(PyObject *callable, PyObject *const *args, +PyObject_VectorcallDict(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwargs) { PyThreadState *tstate = _PyThreadState_GET(); @@ -204,8 +204,8 @@ PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *kwargs) { PyThreadState *tstate = _PyThreadState_GET(); - /* get vectorcallfunc as in _PyVectorcall_Function, but without - * the _Py_TPFLAGS_HAVE_VECTORCALL check */ + /* get vectorcallfunc as in PyVectorcall_Function, but without + * the Py_TPFLAGS_HAVE_VECTORCALL check */ Py_ssize_t offset = Py_TYPE(callable)->tp_vectorcall_offset; if (offset <= 0) { _PyErr_Format(tstate, PyExc_TypeError, @@ -259,7 +259,7 @@ _PyObject_Call(PyThreadState *tstate, PyObject *callable, assert(PyTuple_Check(args)); assert(kwargs == NULL || PyDict_Check(kwargs)); - if (_PyVectorcall_Function(callable) != NULL) { + if (PyVectorcall_Function(callable) != NULL) { return PyVectorcall_Call(callable, args, kwargs); } else { @@ -796,7 +796,7 @@ object_vacall(PyThreadState *tstate, PyObject *base, PyObject * -_PyObject_VectorcallMethod(PyObject *name, PyObject *const *args, +PyObject_VectorcallMethod(PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames) { assert(name != NULL); diff --git a/Objects/classobject.c b/Objects/classobject.c index fb89b8aa69..33afbcd874 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -350,7 +350,7 @@ PyTypeObject PyMethod_Type = { PyObject_GenericSetAttr, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - _Py_TPFLAGS_HAVE_VECTORCALL, /* tp_flags */ + Py_TPFLAGS_HAVE_VECTORCALL, /* tp_flags */ method_doc, /* tp_doc */ (traverseproc)method_traverse, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 49c26eb069..aaaa4479e4 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -454,7 +454,7 @@ classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args, if (bound == NULL) { return NULL; } - PyObject *res = _PyObject_FastCallDict(bound, _PyTuple_ITEMS(args)+1, + PyObject *res = PyObject_VectorcallDict(bound, _PyTuple_ITEMS(args)+1, argc-1, kwds); Py_DECREF(bound); return res; @@ -673,7 +673,7 @@ PyTypeObject PyMethodDescr_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - _Py_TPFLAGS_HAVE_VECTORCALL | + Py_TPFLAGS_HAVE_VECTORCALL | Py_TPFLAGS_METHOD_DESCRIPTOR, /* tp_flags */ 0, /* tp_doc */ descr_traverse, /* tp_traverse */ @@ -1493,7 +1493,7 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type) return NULL; } - return _PyObject_CallOneArg(gs->prop_get, obj); + return PyObject_CallOneArg(gs->prop_get, obj); } static int @@ -1514,7 +1514,7 @@ property_descr_set(PyObject *self, PyObject *obj, PyObject *value) return -1; } if (value == NULL) - res = _PyObject_CallOneArg(func, obj); + res = PyObject_CallOneArg(func, obj); else res = PyObject_CallFunctionObjArgs(func, obj, value, NULL); if (res == NULL) diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 164104ed7e..8f6ce3996a 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -2127,7 +2127,7 @@ dict_subscript(PyDictObject *mp, PyObject *key) _Py_IDENTIFIER(__missing__); missing = _PyObject_LookupSpecial((PyObject *)mp, &PyId___missing__); if (missing != NULL) { - res = _PyObject_CallOneArg(missing, key); + res = PyObject_CallOneArg(missing, key); Py_DECREF(missing); return res; } diff --git a/Objects/fileobject.c b/Objects/fileobject.c index c0eff8bed5..840d17bee6 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -137,7 +137,7 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags) Py_DECREF(writer); return -1; } - result = _PyObject_CallOneArg(writer, value); + result = PyObject_CallOneArg(writer, value); Py_DECREF(value); Py_DECREF(writer); if (result == NULL) diff --git a/Objects/floatobject.c b/Objects/floatobject.c index dfc5b196f1..648030b659 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -1490,7 +1490,7 @@ float_fromhex(PyTypeObject *type, PyObject *string) goto parse_error; result = PyFloat_FromDouble(negate ? -x : x); if (type != &PyFloat_Type && result != NULL) { - Py_SETREF(result, _PyObject_CallOneArg((PyObject *)type, result)); + Py_SETREF(result, PyObject_CallOneArg((PyObject *)type, result)); } return result; diff --git a/Objects/funcobject.c b/Objects/funcobject.c index ebe68adc33..419db33602 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -654,7 +654,7 @@ PyTypeObject PyFunction_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - _Py_TPFLAGS_HAVE_VECTORCALL | + Py_TPFLAGS_HAVE_VECTORCALL | Py_TPFLAGS_METHOD_DESCRIPTOR, /* tp_flags */ func_new__doc__, /* tp_doc */ (traverseproc)func_traverse, /* tp_traverse */ diff --git a/Objects/genobject.c b/Objects/genobject.c index 652c2903dd..576d6856c7 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -58,7 +58,7 @@ _PyGen_Finalize(PyObject *self) /* Save the current exception, if any. */ PyErr_Fetch(&error_type, &error_value, &error_traceback); - res = _PyObject_CallOneArg(finalizer, self); + res = PyObject_CallOneArg(finalizer, self); if (res == NULL) { PyErr_WriteUnraisable(self); @@ -563,7 +563,7 @@ _PyGen_SetStopIterationValue(PyObject *value) return 0; } /* Construct an exception instance manually with - * _PyObject_CallOneArg and pass it to PyErr_SetObject. + * PyObject_CallOneArg and pass it to PyErr_SetObject. * * We do this to handle a situation when "value" is a tuple, in which * case PyErr_SetObject would set the value of StopIteration to @@ -571,7 +571,7 @@ _PyGen_SetStopIterationValue(PyObject *value) * * (See PyErr_SetObject/_PyErr_CreateException code for details.) */ - e = _PyObject_CallOneArg(PyExc_StopIteration, value); + e = PyObject_CallOneArg(PyExc_StopIteration, value); if (e == NULL) { return -1; } @@ -1264,7 +1264,7 @@ async_gen_init_hooks(PyAsyncGenObject *o) PyObject *res; Py_INCREF(firstiter); - res = _PyObject_CallOneArg(firstiter, (PyObject *)o); + res = PyObject_CallOneArg(firstiter, (PyObject *)o); Py_DECREF(firstiter); if (res == NULL) { return 1; diff --git a/Objects/listobject.c b/Objects/listobject.c index a406e70694..3c39c6444b 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2226,7 +2226,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse) } for (i = 0; i < saved_ob_size ; i++) { - keys[i] = _PyObject_CallOneArg(keyfunc, saved_ob_item[i]); + keys[i] = PyObject_CallOneArg(keyfunc, saved_ob_item[i]); if (keys[i] == NULL) { for (i=i-1 ; i>=0 ; i--) Py_DECREF(keys[i]); diff --git a/Objects/longobject.c b/Objects/longobject.c index b4d0b0575b..5d225cbd2f 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -5547,7 +5547,7 @@ int_from_bytes_impl(PyTypeObject *type, PyObject *bytes_obj, Py_DECREF(bytes); if (long_obj != NULL && type != &PyLong_Type) { - Py_SETREF(long_obj, _PyObject_CallOneArg((PyObject *)type, long_obj)); + Py_SETREF(long_obj, PyObject_CallOneArg((PyObject *)type, long_obj)); } return long_obj; diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index d9dd11733e..906d1cef69 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -1963,7 +1963,7 @@ struct_get_unpacker(const char *fmt, Py_ssize_t itemsize) if (format == NULL) goto error; - structobj = _PyObject_CallOneArg(Struct, format); + structobj = PyObject_CallOneArg(Struct, format); if (structobj == NULL) goto error; @@ -2002,7 +2002,7 @@ struct_unpack_single(const char *ptr, struct unpacker *x) PyObject *v; memcpy(x->item, ptr, x->itemsize); - v = _PyObject_CallOneArg(x->unpack_from, x->mview); + v = PyObject_CallOneArg(x->unpack_from, x->mview); if (v == NULL) return NULL; diff --git a/Objects/methodobject.c b/Objects/methodobject.c index 2a8111fea1..1d54c4cea6 100644 --- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -298,7 +298,7 @@ PyTypeObject PyCFunction_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - _Py_TPFLAGS_HAVE_VECTORCALL, /* tp_flags */ + Py_TPFLAGS_HAVE_VECTORCALL, /* tp_flags */ 0, /* tp_doc */ (traverseproc)meth_traverse, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index 0a593261c4..30de53d902 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -738,7 +738,7 @@ module_getattro(PyModuleObject *m, PyObject *name) _Py_IDENTIFIER(__getattr__); getattr = _PyDict_GetItemId(m->md_dict, &PyId___getattr__); if (getattr) { - return _PyObject_CallOneArg(getattr, name); + return PyObject_CallOneArg(getattr, name); } mod_name = _PyDict_GetItemId(m->md_dict, &PyId___name__); if (mod_name && PyUnicode_Check(mod_name)) { diff --git a/Objects/typeobject.c b/Objects/typeobject.c index e6a84b017a..f32ccb1379 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -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; diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index aa874f2a12..68e4f6af13 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -4250,7 +4250,7 @@ unicode_decode_call_errorhandler_wchar( if (*exceptionObject == NULL) goto onError; - restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject); + restuple = PyObject_CallOneArg(*errorHandler, *exceptionObject); if (restuple == NULL) goto onError; if (!PyTuple_Check(restuple)) { @@ -4354,7 +4354,7 @@ unicode_decode_call_errorhandler_writer( if (*exceptionObject == NULL) goto onError; - restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject); + restuple = PyObject_CallOneArg(*errorHandler, *exceptionObject); if (restuple == NULL) goto onError; if (!PyTuple_Check(restuple)) { @@ -6801,7 +6801,7 @@ unicode_encode_call_errorhandler(const char *errors, if (*exceptionObject == NULL) return NULL; - restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject); + restuple = PyObject_CallOneArg(*errorHandler, *exceptionObject); if (restuple == NULL) return NULL; if (!PyTuple_Check(restuple)) { @@ -8783,7 +8783,7 @@ unicode_translate_call_errorhandler(const char *errors, if (*exceptionObject == NULL) return NULL; - restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject); + restuple = PyObject_CallOneArg(*errorHandler, *exceptionObject); if (restuple == NULL) return NULL; if (!PyTuple_Check(restuple)) { diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index 18c737e7e4..7a5d9fb88a 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -933,7 +933,7 @@ PyWeakref_GetObject(PyObject *ref) static void handle_callback(PyWeakReference *ref, PyObject *callback) { - PyObject *cbresult = _PyObject_CallOneArg(callback, (PyObject *)ref); + PyObject *cbresult = PyObject_CallOneArg(callback, (PyObject *)ref); if (cbresult == NULL) PyErr_WriteUnraisable(callback); |