From 368ed59ef92749574e8a176c3393e5f7dbb0f4b2 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 26 Nov 2019 14:30:53 +0100 Subject: [PATCH 01/10] Remove leading underscores from provisional call/Vectorcall API Change made automatically with: for name in \ PyObject_Vectorcall \ Py_TPFLAGS_HAVE_VECTORCALL \ PyObject_VectorcallMethod \ PyObject_FastCallDict \ 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 --- Doc/c-api/call.rst | 38 +++++++++++++-------------- Doc/c-api/typeobj.rst | 12 ++++----- Include/cpython/abstract.h | 34 ++++++++++++------------ Include/object.h | 2 +- Lib/test/test_call.py | 6 ++--- Misc/NEWS.d/3.9.0a1.rst | 8 +++--- Modules/_asynciomodule.c | 22 ++++++++-------- Modules/_collectionsmodule.c | 2 +- Modules/_csv.c | 6 ++--- Modules/_ctypes/callproc.c | 8 +++--- Modules/_elementtree.c | 16 ++++++------ Modules/_functoolsmodule.c | 4 +-- Modules/_io/bufferedio.c | 30 ++++++++++----------- Modules/_io/iobase.c | 16 ++++++------ Modules/_io/stringio.c | 2 +- Modules/_io/textio.c | 42 +++++++++++++++--------------- Modules/_json.c | 12 ++++----- Modules/_operator.c | 2 +- Modules/_pickle.c | 10 +++---- Modules/_posixsubprocess.c | 6 ++--- Modules/_randommodule.c | 2 +- Modules/_sqlite/cache.c | 2 +- Modules/_sqlite/connection.c | 6 ++--- Modules/_sqlite/cursor.c | 2 +- Modules/_sqlite/microprotocols.c | 6 ++--- Modules/_sre.c | 2 +- Modules/_struct.c | 2 +- Modules/_testcapimodule.c | 10 +++---- Modules/_xxtestfuzz/fuzzer.c | 4 +-- Modules/cjkcodecs/cjkcodecs.h | 2 +- Modules/cjkcodecs/multibytecodec.c | 2 +- Modules/gcmodule.c | 2 +- Modules/itertoolsmodule.c | 8 +++--- Modules/pyexpat.c | 2 +- Objects/abstract.c | 8 +++--- Objects/bytearrayobject.c | 4 +-- Objects/bytesobject.c | 2 +- Objects/call.c | 14 +++++----- Objects/classobject.c | 2 +- Objects/descrobject.c | 8 +++--- Objects/dictobject.c | 2 +- Objects/fileobject.c | 2 +- Objects/floatobject.c | 2 +- Objects/funcobject.c | 2 +- Objects/genobject.c | 8 +++--- Objects/listobject.c | 2 +- Objects/longobject.c | 2 +- Objects/memoryobject.c | 4 +-- Objects/methodobject.c | 2 +- Objects/moduleobject.c | 2 +- Objects/typeobject.c | 20 +++++++------- Objects/unicodeobject.c | 8 +++--- Objects/weakrefobject.c | 2 +- Python/_warnings.c | 8 +++--- Python/bltinmodule.c | 16 ++++++------ Python/ceval.c | 12 ++++----- Python/codecs.c | 4 +-- Python/errors.c | 6 ++--- Python/import.c | 2 +- Python/sysmodule.c | 2 +- 60 files changed, 238 insertions(+), 238 deletions(-) diff --git a/Doc/c-api/call.rst b/Doc/c-api/call.rst index 0833531b1d5ee1..6c62a6832f93b9 100644 --- a/Doc/c-api/call.rst +++ b/Doc/c-api/call.rst @@ -69,7 +69,7 @@ the arguments to an args tuple and kwargs dict anyway, then there is no point in implementing vectorcall. Classes can implement the vectorcall protocol by enabling the -:const:`_Py_TPFLAGS_HAVE_VECTORCALL` flag and setting +:const:`Py_TPFLAGS_HAVE_VECTORCALL` flag and setting :c:member:`~PyTypeObject.tp_vectorcall_offset` to the offset inside the object structure where a *vectorcallfunc* appears. This is a pointer to a function with the following signature: @@ -97,7 +97,7 @@ This is a pointer to a function with the following signature: argument 1 (not 0) in the allocated vector. The callee must restore the value of ``args[-1]`` before returning. - For :c:func:`_PyObject_VectorcallMethod`, this flag means instead that + For :c:func:`PyObject_VectorcallMethod`, this flag means instead that ``args[0]`` may be changed. Whenever they can do so cheaply (without additional allocation), callers @@ -107,7 +107,7 @@ This is a pointer to a function with the following signature: To call an object that implements vectorcall, use a :ref:`call API ` function as with any other callable. -:c:func:`_PyObject_Vectorcall` will usually be most efficient. +:c:func:`PyObject_Vectorcall` will usually be most efficient. Recursion Control @@ -139,7 +139,7 @@ Vectorcall Support API .. versionadded:: 3.8 -.. c:function:: vectorcallfunc _PyVectorcall_Function(PyObject *op) +.. c:function:: vectorcallfunc PyVectorcall_Function(PyObject *op) If *op* does not support the vectorcall protocol (either because the type does not or because the specific instance does not), return *NULL*. @@ -147,7 +147,7 @@ Vectorcall Support API This function never raises an exception. This is mostly useful to check whether or not *op* supports vectorcall, - which can be done by checking ``_PyVectorcall_Function(op) != NULL``. + which can be done by checking ``PyVectorcall_Function(op) != NULL``. .. versionadded:: 3.8 @@ -158,7 +158,7 @@ Vectorcall Support API This is a specialized function, intended to be put in the :c:member:`~PyTypeObject.tp_call` slot or be used in an implementation of ``tp_call``. - It does not check the :const:`_Py_TPFLAGS_HAVE_VECTORCALL` flag + It does not check the :const:`Py_TPFLAGS_HAVE_VECTORCALL` flag and it does not fall back to ``tp_call``. .. versionadded:: 3.8 @@ -185,7 +185,7 @@ please see individual documentation for details. +------------------------------------------+------------------+--------------------+---------------+ | :c:func:`PyObject_CallNoArgs` | ``PyObject *`` | --- | --- | +------------------------------------------+------------------+--------------------+---------------+ -| :c:func:`_PyObject_CallOneArg` | ``PyObject *`` | 1 object | --- | +| :c:func:`PyObject_CallOneArg` | ``PyObject *`` | 1 object | --- | +------------------------------------------+------------------+--------------------+---------------+ | :c:func:`PyObject_CallObject` | ``PyObject *`` | tuple/``NULL`` | --- | +------------------------------------------+------------------+--------------------+---------------+ @@ -197,15 +197,15 @@ please see individual documentation for details. +------------------------------------------+------------------+--------------------+---------------+ | :c:func:`PyObject_CallMethodObjArgs` | obj + name | variadic | --- | +------------------------------------------+------------------+--------------------+---------------+ -| :c:func:`_PyObject_CallMethodNoArgs` | obj + name | --- | --- | +| :c:func:`PyObject_CallMethodNoArgs` | obj + name | --- | --- | +------------------------------------------+------------------+--------------------+---------------+ -| :c:func:`_PyObject_CallMethodOneArg` | obj + name | 1 object | --- | +| :c:func:`PyObject_CallMethodOneArg` | obj + name | 1 object | --- | +------------------------------------------+------------------+--------------------+---------------+ -| :c:func:`_PyObject_Vectorcall` | ``PyObject *`` | vectorcall | vectorcall | +| :c:func:`PyObject_Vectorcall` | ``PyObject *`` | vectorcall | vectorcall | +------------------------------------------+------------------+--------------------+---------------+ -| :c:func:`_PyObject_FastCallDict` | ``PyObject *`` | vectorcall | dict/``NULL`` | +| :c:func:`PyObject_FastCallDict` | ``PyObject *`` | vectorcall | dict/``NULL`` | +------------------------------------------+------------------+--------------------+---------------+ -| :c:func:`_PyObject_VectorcallMethod` | arg + name | vectorcall | vectorcall | +| :c:func:`PyObject_VectorcallMethod` | arg + name | vectorcall | vectorcall | +------------------------------------------+------------------+--------------------+---------------+ @@ -235,7 +235,7 @@ please see individual documentation for details. .. versionadded:: 3.9 -.. c:function:: PyObject* _PyObject_CallOneArg(PyObject *callable, PyObject *arg) +.. c:function:: PyObject* PyObject_CallOneArg(PyObject *callable, PyObject *arg) Call a callable Python object *callable* with exactly 1 positional argument *arg* and no keyword arguments. @@ -320,7 +320,7 @@ please see individual documentation for details. *NULL* on failure. -.. c:function:: PyObject* _PyObject_CallMethodNoArgs(PyObject *obj, PyObject *name) +.. c:function:: PyObject* PyObject_CallMethodNoArgs(PyObject *obj, PyObject *name) Call a method of the Python object *obj* without arguments, where the name of the method is given as a Python string object in *name*. @@ -331,7 +331,7 @@ please see individual documentation for details. .. versionadded:: 3.9 -.. c:function:: PyObject* _PyObject_CallMethodOneArg(PyObject *obj, PyObject *name, PyObject *arg) +.. c:function:: PyObject* PyObject_CallMethodOneArg(PyObject *obj, PyObject *name, PyObject *arg) Call a method of the Python object *obj* with a single positional argument *arg*, where the name of the method is given as a Python string object in @@ -343,7 +343,7 @@ please see individual documentation for details. .. versionadded:: 3.9 -.. c:function:: PyObject* _PyObject_Vectorcall(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames) +.. c:function:: PyObject* PyObject_Vectorcall(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames) Call a callable Python object *callable*. The arguments are the same as for :c:type:`vectorcallfunc`. @@ -361,7 +361,7 @@ please see individual documentation for details. .. versionadded:: 3.8 -.. c:function:: PyObject* _PyObject_FastCallDict(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwdict) +.. c:function:: PyObject* PyObject_FastCallDict(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwdict) Call *callable* with positional arguments passed exactly as in the vectorcall_ protocol, but with keyword arguments passed as a dictionary *kwdict*. @@ -381,7 +381,7 @@ please see individual documentation for details. .. versionadded:: 3.8 -.. c:function:: PyObject* _PyObject_VectorcallMethod(PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames) +.. c:function:: PyObject* PyObject_VectorcallMethod(PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames) Call a method using the vectorcall calling convention. The name of the method is given as a Python string *name*. The object whose method is called is @@ -390,7 +390,7 @@ please see individual documentation for details. *nargsf* is the number of positional arguments including *args[0]*, plus :const:`PY_VECTORCALL_ARGUMENTS_OFFSET` if the value of ``args[0]`` may temporarily be changed. Keyword arguments can be passed just like in - :c:func:`_PyObject_Vectorcall`. + :c:func:`PyObject_Vectorcall`. If the object has the :const:`Py_TPFLAGS_METHOD_DESCRIPTOR` feature, this will call the unbound method object with the full diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index 7b205c044953b8..be908126946162 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -693,15 +693,15 @@ and :c:type:`PyType_Type` effectively act as defaults.) a more efficient alternative of the simpler :c:member:`~PyTypeObject.tp_call`. - This field is only used if the flag :const:`_Py_TPFLAGS_HAVE_VECTORCALL` + This field is only used if the flag :const:`Py_TPFLAGS_HAVE_VECTORCALL` is set. If so, this must be a positive integer containing the offset in the instance of a :c:type:`vectorcallfunc` pointer. The *vectorcallfunc* pointer may be ``NULL``, in which case the instance behaves - as if :const:`_Py_TPFLAGS_HAVE_VECTORCALL` was not set: calling the instance + as if :const:`Py_TPFLAGS_HAVE_VECTORCALL` was not set: calling the instance falls back to :c:member:`~PyTypeObject.tp_call`. - Any class that sets ``_Py_TPFLAGS_HAVE_VECTORCALL`` must also set + Any class that sets ``Py_TPFLAGS_HAVE_VECTORCALL`` must also set :c:member:`~PyTypeObject.tp_call` and make sure its behaviour is consistent with the *vectorcallfunc* function. This can be done by setting *tp_call* to :c:func:`PyVectorcall_Call`. @@ -728,7 +728,7 @@ and :c:type:`PyType_Type` effectively act as defaults.) **Inheritance:** This field is always inherited. - However, the :const:`_Py_TPFLAGS_HAVE_VECTORCALL` flag is not + However, the :const:`Py_TPFLAGS_HAVE_VECTORCALL` flag is not always inherited. If it's not, then the subclass won't use :ref:`vectorcall `, except when :c:func:`PyVectorcall_Call` is explicitly called. @@ -1162,7 +1162,7 @@ and :c:type:`PyType_Type` effectively act as defaults.) type structure. - .. data:: _Py_TPFLAGS_HAVE_VECTORCALL + .. data:: Py_TPFLAGS_HAVE_VECTORCALL This bit is set when the class implements the :ref:`vectorcall protocol `. @@ -1172,7 +1172,7 @@ and :c:type:`PyType_Type` effectively act as defaults.) This bit is inherited for *static* subtypes if :c:member:`~PyTypeObject.tp_call` is also inherited. - `Heap types`_ do not inherit ``_Py_TPFLAGS_HAVE_VECTORCALL``. + `Heap types`_ do not inherit ``Py_TPFLAGS_HAVE_VECTORCALL``. .. note:: diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index 2c4eae70b96901..cd13f98590d59f 100644 --- a/Include/cpython/abstract.h +++ b/Include/cpython/abstract.h @@ -29,7 +29,7 @@ PyAPI_FUNC(PyObject *) _PyStack_AsDict( /* Suggested size (number of positional arguments) for arrays of PyObject* allocated on a C stack to avoid allocating memory on the heap memory. Such array is used to pass positional arguments to call functions of the - _PyObject_Vectorcall() family. + PyObject_Vectorcall() family. The size is chosen to not abuse the C stack and so limit the risk of stack overflow. The size is also chosen to allow using the small stack for most @@ -45,8 +45,8 @@ PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult( /* === Vectorcall protocol (PEP 590) ============================= */ -/* Call callable using tp_call. Arguments are like _PyObject_Vectorcall() - or _PyObject_FastCallDict() (both forms are supported), +/* Call callable using tp_call. Arguments are like PyObject_Vectorcall() + or PyObject_FastCallDict() (both forms are supported), except that nargs is plainly the number of arguments without flags. */ PyAPI_FUNC(PyObject *) _PyObject_MakeTpCall( PyThreadState *tstate, @@ -63,11 +63,11 @@ PyVectorcall_NARGS(size_t n) } static inline vectorcallfunc -_PyVectorcall_Function(PyObject *callable) +PyVectorcall_Function(PyObject *callable) { assert(callable != NULL); PyTypeObject *tp = Py_TYPE(callable); - if (!PyType_HasFeature(tp, _Py_TPFLAGS_HAVE_VECTORCALL)) { + if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL)) { return NULL; } assert(PyCallable_Check(callable)); @@ -103,7 +103,7 @@ _PyObject_VectorcallTstate(PyThreadState *tstate, PyObject *callable, assert(kwnames == NULL || PyTuple_Check(kwnames)); assert(args != NULL || PyVectorcall_NARGS(nargsf) == 0); - vectorcallfunc func = _PyVectorcall_Function(callable); + vectorcallfunc func = PyVectorcall_Function(callable); if (func == NULL) { Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); return _PyObject_MakeTpCall(tstate, callable, args, nargs, kwnames); @@ -113,7 +113,7 @@ _PyObject_VectorcallTstate(PyThreadState *tstate, PyObject *callable, } static inline PyObject * -_PyObject_Vectorcall(PyObject *callable, PyObject *const *args, +PyObject_Vectorcall(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames) { PyThreadState *tstate = PyThreadState_GET(); @@ -121,9 +121,9 @@ _PyObject_Vectorcall(PyObject *callable, PyObject *const *args, args, nargsf, kwnames); } -/* Same as _PyObject_Vectorcall except that keyword arguments are passed as +/* Same as PyObject_Vectorcall except that keyword arguments are passed as dict, which may be NULL if there are no keyword arguments. */ -PyAPI_FUNC(PyObject *) _PyObject_FastCallDict( +PyAPI_FUNC(PyObject *) PyObject_FastCallDict( PyObject *callable, PyObject *const *args, size_t nargsf, @@ -133,7 +133,7 @@ PyAPI_FUNC(PyObject *) _PyObject_FastCallDict( "tuple" and keyword arguments "dict". "dict" may also be NULL */ PyAPI_FUNC(PyObject *) PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict); -/* Same as _PyObject_Vectorcall except without keyword arguments */ +/* Same as PyObject_Vectorcall except without keyword arguments */ static inline PyObject * _PyObject_FastCall(PyObject *func, PyObject *const *args, Py_ssize_t nargs) { @@ -151,7 +151,7 @@ _PyObject_CallNoArg(PyObject *func) { } static inline PyObject * -_PyObject_CallOneArg(PyObject *func, PyObject *arg) +PyObject_CallOneArg(PyObject *func, PyObject *arg) { assert(arg != NULL); PyObject *_args[2]; @@ -162,23 +162,23 @@ _PyObject_CallOneArg(PyObject *func, PyObject *arg) return _PyObject_VectorcallTstate(tstate, func, args, nargsf, NULL); } -PyAPI_FUNC(PyObject *) _PyObject_VectorcallMethod( +PyAPI_FUNC(PyObject *) PyObject_VectorcallMethod( PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames); static inline PyObject * -_PyObject_CallMethodNoArgs(PyObject *self, PyObject *name) +PyObject_CallMethodNoArgs(PyObject *self, PyObject *name) { - return _PyObject_VectorcallMethod(name, &self, + return PyObject_VectorcallMethod(name, &self, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); } static inline PyObject * -_PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg) +PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg) { assert(arg != NULL); PyObject *args[2] = {self, arg}; - return _PyObject_VectorcallMethod(name, args, + return PyObject_VectorcallMethod(name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); } @@ -207,7 +207,7 @@ _PyObject_VectorcallMethodId( if (!oname) { return NULL; } - return _PyObject_VectorcallMethod(oname, args, nargsf, kwnames); + return PyObject_VectorcallMethod(oname, args, nargsf, kwnames); } static inline PyObject * diff --git a/Include/object.h b/Include/object.h index a9d434b5108068..3834909b915dc2 100644 --- a/Include/object.h +++ b/Include/object.h @@ -290,7 +290,7 @@ given type object has a specified feature. /* Set if the type implements the vectorcall protocol (PEP 590) */ #ifndef Py_LIMITED_API -#define _Py_TPFLAGS_HAVE_VECTORCALL (1UL << 11) +#define Py_TPFLAGS_HAVE_VECTORCALL (1UL << 11) #endif /* Set if the type is 'ready' -- fully initialized */ diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py index d178aa4ec2bd2c..0249109c45bfad 100644 --- a/Lib/test/test_call.py +++ b/Lib/test/test_call.py @@ -468,7 +468,7 @@ def test_fastcall(self): self.check_result(result, expected) def test_vectorcall_dict(self): - # Test _PyObject_FastCallDict() + # Test PyObject_FastCallDict() for func, args, expected in self.CALLS_POSARGS: with self.subTest(func=func, args=args): @@ -487,7 +487,7 @@ def test_vectorcall_dict(self): self.check_result(result, expected) def test_vectorcall(self): - # Test _PyObject_Vectorcall() + # Test PyObject_Vectorcall() for func, args, expected in self.CALLS_POSARGS: with self.subTest(func=func, args=args): @@ -594,7 +594,7 @@ def test_vectorcall(self): # 1. vectorcall using PyVectorcall_Call() # (only for objects that support vectorcall directly) # 2. normal call - # 3. vectorcall using _PyObject_Vectorcall() + # 3. vectorcall using PyObject_Vectorcall() # 4. call as bound method # 5. call using functools.partial diff --git a/Misc/NEWS.d/3.9.0a1.rst b/Misc/NEWS.d/3.9.0a1.rst index fb74d3622263d4..f822331401403d 100644 --- a/Misc/NEWS.d/3.9.0a1.rst +++ b/Misc/NEWS.d/3.9.0a1.rst @@ -678,7 +678,7 @@ The :keyword:`assert` statement now works properly if the Removed object cache (``free_list``) for bound method objects. Temporary bound method objects are less used than before thanks to the ``LOAD_METHOD`` -opcode and the ``_PyObject_VectorcallMethod`` C API. +opcode and the ``PyObject_VectorcallMethod`` C API. .. @@ -5676,7 +5676,7 @@ Exclude Python-ast.h, ast.h and asdl.h from the limited API. .. nonce: vftT4f .. section: C API -Add new function ``_PyObject_CallOneArg`` for calling an object with one +Add new function ``PyObject_CallOneArg`` for calling an object with one positional argument. .. @@ -5696,8 +5696,8 @@ Add :func:`PyConfig_SetWideStringList` function. .. section: C API Add fast functions for calling methods: -:c:func:`_PyObject_VectorcallMethod`, :c:func:`_PyObject_CallMethodNoArgs` -and :c:func:`_PyObject_CallMethodOneArg`. +:c:func:`PyObject_VectorcallMethod`, :c:func:`PyObject_CallMethodNoArgs` +and :c:func:`PyObject_CallMethodOneArg`. .. diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index 70da40a8a3b863..fb6e4cf26edeba 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -142,7 +142,7 @@ _is_coroutine(PyObject *coro) Do this check after 'future_init()'; in case we need to raise an error, __del__ needs a properly initialized object. */ - PyObject *res = _PyObject_CallOneArg(asyncio_iscoroutine_func, coro); + PyObject *res = PyObject_CallOneArg(asyncio_iscoroutine_func, coro); if (res == NULL) { return -1; } @@ -367,7 +367,7 @@ call_soon(PyObject *loop, PyObject *func, PyObject *arg, PyObject *ctx) } stack[nargs] = (PyObject *)ctx; - handle = _PyObject_Vectorcall(callable, stack, nargs, context_kwname); + handle = PyObject_Vectorcall(callable, stack, nargs, context_kwname); Py_DECREF(callable); } @@ -1287,7 +1287,7 @@ static PyObject * _asyncio_Future__repr_info_impl(FutureObj *self) /*[clinic end generated code: output=fa69e901bd176cfb input=f21504d8e2ae1ca2]*/ { - return _PyObject_CallOneArg(asyncio_future_repr_info_func, (PyObject *)self); + return PyObject_CallOneArg(asyncio_future_repr_info_func, (PyObject *)self); } static PyObject * @@ -1363,7 +1363,7 @@ FutureObj_finalize(FutureObj *fut) func = _PyObject_GetAttrId(fut->fut_loop, &PyId_call_exception_handler); if (func != NULL) { - PyObject *res = _PyObject_CallOneArg(func, context); + PyObject *res = PyObject_CallOneArg(func, context); if (res == NULL) { PyErr_WriteUnraisable(func); } @@ -2126,13 +2126,13 @@ _asyncio_Task_current_task_impl(PyTypeObject *type, PyObject *loop) Py_DECREF(current_task_func); return NULL; } - ret = _PyObject_CallOneArg(current_task_func, loop); + ret = PyObject_CallOneArg(current_task_func, loop); Py_DECREF(current_task_func); Py_DECREF(loop); return ret; } else { - ret = _PyObject_CallOneArg(current_task_func, loop); + ret = PyObject_CallOneArg(current_task_func, loop); Py_DECREF(current_task_func); return ret; } @@ -2168,7 +2168,7 @@ _asyncio_Task_all_tasks_impl(PyTypeObject *type, PyObject *loop) return NULL; } - res = _PyObject_CallOneArg(all_tasks_func, loop); + res = PyObject_CallOneArg(all_tasks_func, loop); Py_DECREF(all_tasks_func); return res; } @@ -2181,7 +2181,7 @@ static PyObject * _asyncio_Task__repr_info_impl(TaskObj *self) /*[clinic end generated code: output=6a490eb66d5ba34b input=3c6d051ed3ddec8b]*/ { - return _PyObject_CallOneArg(asyncio_task_repr_info_func, (PyObject *)self); + return PyObject_CallOneArg(asyncio_task_repr_info_func, (PyObject *)self); } /*[clinic input] @@ -2431,7 +2431,7 @@ TaskObj_finalize(TaskObj *task) func = _PyObject_GetAttrId(task->task_loop, &PyId_call_exception_handler); if (func != NULL) { - PyObject *res = _PyObject_CallOneArg(func, context); + PyObject *res = PyObject_CallOneArg(func, context); if (res == NULL) { PyErr_WriteUnraisable(func); } @@ -2571,7 +2571,7 @@ task_set_error_soon(TaskObj *task, PyObject *et, const char *format, ...) return NULL; } - PyObject *e = _PyObject_CallOneArg(et, msg); + PyObject *e = PyObject_CallOneArg(et, msg); Py_DECREF(msg); if (e == NULL) { return NULL; @@ -2841,7 +2841,7 @@ task_step_impl(TaskObj *task, PyObject *exc) PyObject *stack[2]; stack[0] = wrapper; stack[1] = (PyObject *)task->task_context; - res = _PyObject_Vectorcall(add_cb, stack, 1, context_kwname); + res = PyObject_Vectorcall(add_cb, stack, 1, context_kwname); Py_DECREF(add_cb); Py_DECREF(wrapper); if (res == NULL) { diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 1d23973fd05661..2dfe72d1c58eed 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -512,7 +512,7 @@ deque_copy(PyObject *deque, PyObject *Py_UNUSED(ignored)) return NULL; } if (old_deque->maxlen < 0) - result = _PyObject_CallOneArg((PyObject *)(Py_TYPE(deque)), deque); + result = PyObject_CallOneArg((PyObject *)(Py_TYPE(deque)), deque); else result = PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi", deque, old_deque->maxlen, NULL); diff --git a/Modules/_csv.c b/Modules/_csv.c index aaf377650c0b2b..cf94cf276ce7db 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -514,10 +514,10 @@ _call_dialect(PyObject *dialect_inst, PyObject *kwargs) { PyObject *type = (PyObject *)&Dialect_Type; if (dialect_inst) { - return _PyObject_FastCallDict(type, &dialect_inst, 1, kwargs); + return PyObject_FastCallDict(type, &dialect_inst, 1, kwargs); } else { - return _PyObject_FastCallDict(type, NULL, 0, kwargs); + return PyObject_FastCallDict(type, NULL, 0, kwargs); } } @@ -1240,7 +1240,7 @@ csv_writerow(WriterObj *self, PyObject *seq) if (line == NULL) { return NULL; } - result = _PyObject_CallOneArg(self->write, line); + result = PyObject_CallOneArg(self->write, line); Py_DECREF(line); return result; } diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 7b13fa041a205c..34a7f6a75c3858 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -945,7 +945,7 @@ static PyObject *GetResult(PyObject *restype, void *result, PyObject *checker) if (!checker || !retval) return retval; - v = _PyObject_CallOneArg(checker, retval); + v = PyObject_CallOneArg(checker, retval); if (v == NULL) _PyTraceback_Add("GetResult", "_ctypes/callproc.c", __LINE__-2); Py_DECREF(retval); @@ -1138,7 +1138,7 @@ PyObject *_ctypes_callproc(PPROC pProc, if (argtypes && argtype_count > i) { PyObject *v; converter = PyTuple_GET_ITEM(argtypes, i); - v = _PyObject_CallOneArg(converter, arg); + v = PyObject_CallOneArg(converter, arg); if (v == NULL) { _ctypes_extend_error(PyExc_ArgError, "argument %zd: ", i+1); goto cleanup; @@ -1834,7 +1834,7 @@ pointer(PyObject *self, PyObject *arg) typ = PyDict_GetItemWithError(_ctypes_ptrtype_cache, (PyObject *)Py_TYPE(arg)); if (typ) { - return _PyObject_CallOneArg(typ, arg); + return PyObject_CallOneArg(typ, arg); } else if (PyErr_Occurred()) { return NULL; @@ -1842,7 +1842,7 @@ pointer(PyObject *self, PyObject *arg) typ = POINTER(NULL, (PyObject *)Py_TYPE(arg)); if (typ == NULL) return NULL; - result = _PyObject_CallOneArg(typ, arg); + result = PyObject_CallOneArg(typ, arg); Py_DECREF(typ); return result; } diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index c096eab43ea6a8..a04b295378e4fe 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2671,7 +2671,7 @@ treebuilder_append_event(TreeBuilderObject *self, PyObject *action, PyObject *event = PyTuple_Pack(2, action, node); if (event == NULL) return -1; - res = _PyObject_CallOneArg(self->events_append, event); + res = PyObject_CallOneArg(self->events_append, event); Py_DECREF(event); if (res == NULL) return -1; @@ -2837,7 +2837,7 @@ treebuilder_handle_comment(TreeBuilderObject* self, PyObject* text) } if (self->comment_factory) { - comment = _PyObject_CallOneArg(self->comment_factory, text); + comment = PyObject_CallOneArg(self->comment_factory, text); if (!comment) return NULL; @@ -3179,7 +3179,7 @@ expat_set_error(enum XML_Error error_code, Py_ssize_t line, Py_ssize_t column, if (errmsg == NULL) return; - error = _PyObject_CallOneArg(st->parseerror_obj, errmsg); + error = PyObject_CallOneArg(st->parseerror_obj, errmsg); Py_DECREF(errmsg); if (!error) return; @@ -3242,7 +3242,7 @@ expat_default_handler(XMLParserObject* self, const XML_Char* data_in, (TreeBuilderObject*) self->target, value ); else if (self->handle_data) - res = _PyObject_CallOneArg(self->handle_data, value); + res = PyObject_CallOneArg(self->handle_data, value); else res = NULL; Py_XDECREF(res); @@ -3353,7 +3353,7 @@ expat_data_handler(XMLParserObject* self, const XML_Char* data_in, /* shortcut */ res = treebuilder_handle_data((TreeBuilderObject*) self->target, data); else if (self->handle_data) - res = _PyObject_CallOneArg(self->handle_data, data); + res = PyObject_CallOneArg(self->handle_data, data); else res = NULL; @@ -3380,7 +3380,7 @@ expat_end_handler(XMLParserObject* self, const XML_Char* tag_in) else if (self->handle_end) { tag = makeuniversal(self, tag_in); if (tag) { - res = _PyObject_CallOneArg(self->handle_end, tag); + res = PyObject_CallOneArg(self->handle_end, tag); Py_DECREF(tag); } } @@ -3467,7 +3467,7 @@ expat_end_ns_handler(XMLParserObject* self, const XML_Char* prefix_in) if (!prefix) return; - res = _PyObject_CallOneArg(self->handle_end_ns, prefix); + res = PyObject_CallOneArg(self->handle_end_ns, prefix); Py_DECREF(prefix); } @@ -3499,7 +3499,7 @@ expat_comment_handler(XMLParserObject* self, const XML_Char* comment_in) if (!comment) return; - res = _PyObject_CallOneArg(self->handle_comment, comment); + res = PyObject_CallOneArg(self->handle_comment, comment); Py_XDECREF(res); Py_DECREF(comment); } diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 987087b1ac97ba..75fa250d55e62f 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -213,7 +213,7 @@ partial_vectorcall(partialobject *pto, PyObject *const *args, static void partial_setvectorcall(partialobject *pto) { - if (_PyVectorcall_Function(pto->fn) == NULL) { + if (PyVectorcall_Function(pto->fn) == NULL) { /* Don't use vectorcall if the underlying function doesn't support it */ pto->vectorcall = NULL; } @@ -440,7 +440,7 @@ static PyTypeObject partial_type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE | - _Py_TPFLAGS_HAVE_VECTORCALL, /* tp_flags */ + Py_TPFLAGS_HAVE_VECTORCALL, /* tp_flags */ partial_doc, /* tp_doc */ (traverseproc)partial_traverse, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 586e93f25e28f4..9b2439b6d5e8d8 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -461,7 +461,7 @@ static PyObject * buffered_simple_flush(buffered *self, PyObject *args) { CHECK_INITIALIZED(self) - return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_flush); + return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_flush); } static int @@ -513,7 +513,7 @@ buffered_close(buffered *self, PyObject *args) } /* flush() will most probably re-take the lock, so drop it first */ LEAVE_BUFFERED(self) - res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); + res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); if (!ENTER_BUFFERED(self)) return NULL; if (res == NULL) @@ -521,7 +521,7 @@ buffered_close(buffered *self, PyObject *args) else Py_DECREF(res); - res = _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_close); + res = PyObject_CallMethodNoArgs(self->raw, _PyIO_str_close); if (self->buffer) { PyMem_Free(self->buffer); @@ -545,7 +545,7 @@ buffered_detach(buffered *self, PyObject *Py_UNUSED(ignored)) { PyObject *raw, *res; CHECK_INITIALIZED(self) - res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); + res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); if (res == NULL) return NULL; Py_DECREF(res); @@ -562,21 +562,21 @@ static PyObject * buffered_seekable(buffered *self, PyObject *Py_UNUSED(ignored)) { CHECK_INITIALIZED(self) - return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_seekable); + return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_seekable); } static PyObject * buffered_readable(buffered *self, PyObject *Py_UNUSED(ignored)) { CHECK_INITIALIZED(self) - return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_readable); + return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_readable); } static PyObject * buffered_writable(buffered *self, PyObject *Py_UNUSED(ignored)) { CHECK_INITIALIZED(self) - return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_writable); + return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_writable); } static PyObject * @@ -599,14 +599,14 @@ static PyObject * buffered_fileno(buffered *self, PyObject *Py_UNUSED(ignored)) { CHECK_INITIALIZED(self) - return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_fileno); + return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_fileno); } static PyObject * buffered_isatty(buffered *self, PyObject *Py_UNUSED(ignored)) { CHECK_INITIALIZED(self) - return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_isatty); + return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_isatty); } /* Forward decls */ @@ -670,7 +670,7 @@ _buffered_raw_tell(buffered *self) { Py_off_t n; PyObject *res; - res = _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_tell); + res = PyObject_CallMethodNoArgs(self->raw, _PyIO_str_tell); if (res == NULL) return -1; n = PyNumber_AsOff_t(res, PyExc_ValueError); @@ -1323,7 +1323,7 @@ _io__Buffered_truncate_impl(buffered *self, PyObject *pos) goto end; Py_CLEAR(res); } - res = _PyObject_CallMethodOneArg(self->raw, _PyIO_str_truncate, pos); + res = PyObject_CallMethodOneArg(self->raw, _PyIO_str_truncate, pos); if (res == NULL) goto end; /* Reset cached position */ @@ -1350,7 +1350,7 @@ buffered_iternext(buffered *self) line = _buffered_readline(self, -1); } else { - line = _PyObject_CallMethodNoArgs((PyObject *)self, + line = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_readline); if (line && !PyBytes_Check(line)) { PyErr_Format(PyExc_OSError, @@ -1469,7 +1469,7 @@ _bufferedreader_raw_read(buffered *self, char *start, Py_ssize_t len) raised (see issue #10956). */ do { - res = _PyObject_CallMethodOneArg(self->raw, _PyIO_str_readinto, memobj); + res = PyObject_CallMethodOneArg(self->raw, _PyIO_str_readinto, memobj); } while (res == NULL && _PyIO_trap_eintr()); Py_DECREF(memobj); if (res == NULL) @@ -1568,7 +1568,7 @@ _bufferedreader_read_all(buffered *self) } /* Read until EOF or until read() would block. */ - data = _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_read); + data = PyObject_CallMethodNoArgs(self->raw, _PyIO_str_read); if (data == NULL) goto cleanup; if (data != Py_None && !PyBytes_Check(data)) { @@ -1817,7 +1817,7 @@ _bufferedwriter_raw_write(buffered *self, char *start, Py_ssize_t len) */ do { errno = 0; - res = _PyObject_CallMethodOneArg(self->raw, _PyIO_str_write, memobj); + res = PyObject_CallMethodOneArg(self->raw, _PyIO_str_write, memobj); errnum = errno; } while (res == NULL && _PyIO_trap_eintr()); Py_DECREF(memobj); diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c index d51fc944e1a629..1ff35648e550f3 100644 --- a/Modules/_io/iobase.c +++ b/Modules/_io/iobase.c @@ -235,7 +235,7 @@ _io__IOBase_close_impl(PyObject *self) Py_RETURN_NONE; } - res = _PyObject_CallMethodNoArgs(self, _PyIO_str_flush); + res = PyObject_CallMethodNoArgs(self, _PyIO_str_flush); PyErr_Fetch(&exc, &val, &tb); rc = _PyObject_SetAttrId(self, &PyId___IOBase_closed, Py_True); @@ -281,7 +281,7 @@ iobase_finalize(PyObject *self) finalization process. */ if (_PyObject_SetAttrId(self, &PyId__finalizing, Py_True)) PyErr_Clear(); - res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_close); + res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_close); /* Silencing I/O errors is bad, but printing spurious tracebacks is equally as bad, and potentially more frequent (because of shutdown issues). */ @@ -382,7 +382,7 @@ _io__IOBase_seekable_impl(PyObject *self) PyObject * _PyIOBase_check_seekable(PyObject *self, PyObject *args) { - PyObject *res = _PyObject_CallMethodNoArgs(self, _PyIO_str_seekable); + PyObject *res = PyObject_CallMethodNoArgs(self, _PyIO_str_seekable); if (res == NULL) return NULL; if (res != Py_True) { @@ -415,7 +415,7 @@ _io__IOBase_readable_impl(PyObject *self) PyObject * _PyIOBase_check_readable(PyObject *self, PyObject *args) { - PyObject *res = _PyObject_CallMethodNoArgs(self, _PyIO_str_readable); + PyObject *res = PyObject_CallMethodNoArgs(self, _PyIO_str_readable); if (res == NULL) return NULL; if (res != Py_True) { @@ -448,7 +448,7 @@ _io__IOBase_writable_impl(PyObject *self) PyObject * _PyIOBase_check_writable(PyObject *self, PyObject *args) { - PyObject *res = _PyObject_CallMethodNoArgs(self, _PyIO_str_writable); + PyObject *res = PyObject_CallMethodNoArgs(self, _PyIO_str_writable); if (res == NULL) return NULL; if (res != Py_True) { @@ -477,7 +477,7 @@ iobase_enter(PyObject *self, PyObject *args) static PyObject * iobase_exit(PyObject *self, PyObject *args) { - return _PyObject_CallMethodNoArgs(self, _PyIO_str_close); + return PyObject_CallMethodNoArgs(self, _PyIO_str_close); } /* Lower-level APIs */ @@ -556,7 +556,7 @@ _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit) PyObject *b; if (peek != NULL) { - PyObject *readahead = _PyObject_CallOneArg(peek, _PyLong_One); + PyObject *readahead = PyObject_CallOneArg(peek, _PyLong_One); if (readahead == NULL) { /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() when EINTR occurs so we needn't do it ourselves. */ @@ -655,7 +655,7 @@ iobase_iter(PyObject *self) static PyObject * iobase_iternext(PyObject *self) { - PyObject *line = _PyObject_CallMethodNoArgs(self, _PyIO_str_readline); + PyObject *line = PyObject_CallMethodNoArgs(self, _PyIO_str_readline); if (line == NULL) return NULL; diff --git a/Modules/_io/stringio.c b/Modules/_io/stringio.c index 89b29bb8fbb72b..28d54e00d8a7be 100644 --- a/Modules/_io/stringio.c +++ b/Modules/_io/stringio.c @@ -408,7 +408,7 @@ stringio_iternext(stringio *self) } else { /* XXX is subclassing StringIO really supported? */ - line = _PyObject_CallMethodNoArgs((PyObject *)self, + line = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_readline); if (line && !PyUnicode_Check(line)) { PyErr_Format(PyExc_OSError, diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 5ebeb024e57939..b9688a97189404 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -527,7 +527,7 @@ _io_IncrementalNewlineDecoder_getstate_impl(nldecoder_object *self) unsigned long long flag; if (self->decoder != Py_None) { - PyObject *state = _PyObject_CallMethodNoArgs(self->decoder, + PyObject *state = PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_getstate); if (state == NULL) return NULL; @@ -601,7 +601,7 @@ _io_IncrementalNewlineDecoder_reset_impl(nldecoder_object *self) self->seennl = 0; self->pendingcr = 0; if (self->decoder != Py_None) - return _PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_reset); + return PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_reset); else Py_RETURN_NONE; } @@ -963,7 +963,7 @@ _textiowrapper_fix_encoder_state(textio *self) self->encoding_start_of_stream = 1; - PyObject *cookieObj = _PyObject_CallMethodNoArgs( + PyObject *cookieObj = PyObject_CallMethodNoArgs( self->buffer, _PyIO_str_tell); if (cookieObj == NULL) { return -1; @@ -977,7 +977,7 @@ _textiowrapper_fix_encoder_state(textio *self) if (cmp == 0) { self->encoding_start_of_stream = 0; - PyObject *res = _PyObject_CallMethodOneArg( + PyObject *res = PyObject_CallMethodOneArg( self->encoder, _PyIO_str_setstate, _PyLong_Zero); if (res == NULL) { return -1; @@ -1386,7 +1386,7 @@ _io_TextIOWrapper_reconfigure_impl(textio *self, PyObject *encoding, return NULL; } - PyObject *res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); + PyObject *res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); if (res == NULL) { return NULL; } @@ -1525,7 +1525,7 @@ _io_TextIOWrapper_detach_impl(textio *self) { PyObject *buffer, *res; CHECK_ATTACHED(self); - res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); + res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); if (res == NULL) return NULL; Py_DECREF(res); @@ -1597,7 +1597,7 @@ _textiowrapper_writeflush(textio *self) PyObject *ret; do { - ret = _PyObject_CallMethodOneArg(self->buffer, _PyIO_str_write, b); + ret = PyObject_CallMethodOneArg(self->buffer, _PyIO_str_write, b); } while (ret == NULL && _PyIO_trap_eintr()); Py_DECREF(b); if (ret == NULL) @@ -1667,7 +1667,7 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text) self->encoding_start_of_stream = 0; } else - b = _PyObject_CallMethodOneArg(self->encoder, _PyIO_str_encode, text); + b = PyObject_CallMethodOneArg(self->encoder, _PyIO_str_encode, text); Py_DECREF(text); if (b == NULL) @@ -1718,7 +1718,7 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text) } if (needflush) { - ret = _PyObject_CallMethodNoArgs(self->buffer, _PyIO_str_flush); + ret = PyObject_CallMethodNoArgs(self->buffer, _PyIO_str_flush); if (ret == NULL) return NULL; Py_DECREF(ret); @@ -1808,7 +1808,7 @@ textiowrapper_read_chunk(textio *self, Py_ssize_t size_hint) /* To prepare for tell(), we need to snapshot a point in the file * where the decoder's input buffer is empty. */ - PyObject *state = _PyObject_CallMethodNoArgs(self->decoder, + PyObject *state = PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_getstate); if (state == NULL) return -1; @@ -1849,7 +1849,7 @@ textiowrapper_read_chunk(textio *self, Py_ssize_t size_hint) if (chunk_size == NULL) goto fail; - input_chunk = _PyObject_CallMethodOneArg(self->buffer, + input_chunk = PyObject_CallMethodOneArg(self->buffer, (self->has_read1 ? _PyIO_str_read1: _PyIO_str_read), chunk_size); Py_DECREF(chunk_size); @@ -2393,7 +2393,7 @@ _textiowrapper_decoder_setstate(textio *self, cookie_type *cookie) utf-16, that we are expecting a BOM). */ if (cookie->start_pos == 0 && cookie->dec_flags == 0) - res = _PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_reset); + res = PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_reset); else res = _PyObject_CallMethodId(self->decoder, &PyId_setstate, "((yi))", "", cookie->dec_flags); @@ -2408,11 +2408,11 @@ _textiowrapper_encoder_reset(textio *self, int start_of_stream) { PyObject *res; if (start_of_stream) { - res = _PyObject_CallMethodNoArgs(self->encoder, _PyIO_str_reset); + res = PyObject_CallMethodNoArgs(self->encoder, _PyIO_str_reset); self->encoding_start_of_stream = 1; } else { - res = _PyObject_CallMethodOneArg(self->encoder, _PyIO_str_setstate, + res = PyObject_CallMethodOneArg(self->encoder, _PyIO_str_setstate, _PyLong_Zero); self->encoding_start_of_stream = 0; } @@ -2537,7 +2537,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence) goto fail; } - res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); + res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); if (res == NULL) goto fail; Py_DECREF(res); @@ -2552,7 +2552,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence) posobj = PyLong_FromOff_t(cookie.start_pos); if (posobj == NULL) goto fail; - res = _PyObject_CallMethodOneArg(self->buffer, _PyIO_str_seek, posobj); + res = PyObject_CallMethodOneArg(self->buffer, _PyIO_str_seek, posobj); Py_DECREF(posobj); if (res == NULL) goto fail; @@ -2700,14 +2700,14 @@ _io_TextIOWrapper_tell_impl(textio *self) chars_to_skip = self->decoded_chars_used; /* Decoder state will be restored at the end */ - saved_state = _PyObject_CallMethodNoArgs(self->decoder, + saved_state = PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_getstate); if (saved_state == NULL) goto fail; #define DECODER_GETSTATE() do { \ PyObject *dec_buffer; \ - PyObject *_state = _PyObject_CallMethodNoArgs(self->decoder, \ + PyObject *_state = PyObject_CallMethodNoArgs(self->decoder, \ _PyIO_str_getstate); \ if (_state == NULL) \ goto fail; \ @@ -2870,12 +2870,12 @@ _io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos) CHECK_ATTACHED(self) - res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); + res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); if (res == NULL) return NULL; Py_DECREF(res); - return _PyObject_CallMethodOneArg(self->buffer, _PyIO_str_truncate, pos); + return PyObject_CallMethodOneArg(self->buffer, _PyIO_str_truncate, pos); } static PyObject * @@ -3084,7 +3084,7 @@ textiowrapper_iternext(textio *self) line = _textiowrapper_readline(self, -1); } else { - line = _PyObject_CallMethodNoArgs((PyObject *)self, + line = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_readline); if (line && !PyUnicode_Check(line)) { PyErr_Format(PyExc_OSError, diff --git a/Modules/_json.c b/Modules/_json.c index 439414fd59e621..2ef955f587c4ac 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -777,14 +777,14 @@ _parse_object_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ss *next_idx_ptr = idx + 1; if (has_pairs_hook) { - val = _PyObject_CallOneArg(s->object_pairs_hook, rval); + val = PyObject_CallOneArg(s->object_pairs_hook, rval); Py_DECREF(rval); return val; } /* if object_hook is not None: rval = object_hook(rval) */ if (s->object_hook != Py_None) { - val = _PyObject_CallOneArg(s->object_hook, rval); + val = PyObject_CallOneArg(s->object_hook, rval); Py_DECREF(rval); return val; } @@ -890,7 +890,7 @@ _parse_constant(PyScannerObject *s, const char *constant, Py_ssize_t idx, Py_ssi return NULL; /* rval = parse_constant(constant) */ - rval = _PyObject_CallOneArg(s->parse_constant, cstr); + rval = PyObject_CallOneArg(s->parse_constant, cstr); idx += PyUnicode_GET_LENGTH(cstr); Py_DECREF(cstr); *next_idx_ptr = idx; @@ -989,7 +989,7 @@ _match_number_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t start, Py_ idx - start); if (numstr == NULL) return NULL; - rval = _PyObject_CallOneArg(custom_func, numstr); + rval = PyObject_CallOneArg(custom_func, numstr); } else { Py_ssize_t i, n; @@ -1399,7 +1399,7 @@ encoder_encode_string(PyEncoderObject *s, PyObject *obj) if (s->fast_encode) { return s->fast_encode(NULL, obj); } - encoded = _PyObject_CallOneArg(s->encoder, obj); + encoded = PyObject_CallOneArg(s->encoder, obj); if (encoded != NULL && !PyUnicode_Check(encoded)) { PyErr_Format(PyExc_TypeError, "encoder() must return a string, not %.80s", @@ -1485,7 +1485,7 @@ encoder_listencode_obj(PyEncoderObject *s, _PyAccu *acc, return -1; } } - newobj = _PyObject_CallOneArg(s->defaultfn, obj); + newobj = PyObject_CallOneArg(s->defaultfn, obj); if (newobj == NULL) { Py_XDECREF(ident); return -1; diff --git a/Modules/_operator.c b/Modules/_operator.c index 5aa229fa781ebb..6d5ec1753a74a7 100644 --- a/Modules/_operator.c +++ b/Modules/_operator.c @@ -1682,7 +1682,7 @@ methodcaller_reduce(methodcallerobject *mc, PyObject *Py_UNUSED(ignored)) newargs[0] = (PyObject *)Py_TYPE(mc); newargs[1] = mc->name; - constructor = _PyObject_FastCallDict(partial, newargs, 2, mc->kwds); + constructor = PyObject_FastCallDict(partial, newargs, 2, mc->kwds); Py_DECREF(partial); return Py_BuildValue("NO", constructor, mc->args); diff --git a/Modules/_pickle.c b/Modules/_pickle.c index baa0a274196938..ec99536933c6af 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -359,7 +359,7 @@ _Pickle_FastCall(PyObject *func, PyObject *obj) { PyObject *result; - result = _PyObject_CallOneArg(func, obj); + result = PyObject_CallOneArg(func, obj); Py_DECREF(obj); return result; } @@ -420,7 +420,7 @@ call_method(PyObject *func, PyObject *self, PyObject *obj) return PyObject_CallFunctionObjArgs(func, self, obj, NULL); } else { - return _PyObject_CallOneArg(func, obj); + return PyObject_CallOneArg(func, obj); } } @@ -2296,7 +2296,7 @@ _Pickler_write_bytes(PicklerObject *self, return -1; } } - result = _PyObject_CallOneArg(self->write, payload); + result = PyObject_CallOneArg(self->write, payload); Py_XDECREF(mem); if (result == NULL) { return -1; @@ -2504,7 +2504,7 @@ save_picklebuffer(PicklerObject *self, PyObject *obj) } int in_band = 1; if (self->buffer_callback != NULL) { - PyObject *ret = _PyObject_CallOneArg(self->buffer_callback, obj); + PyObject *ret = PyObject_CallOneArg(self->buffer_callback, obj); if (ret == NULL) { return -1; } @@ -4321,7 +4321,7 @@ save(PicklerObject *self, PyObject *obj, int pers_save) * regular reduction mechanism. */ if (self->reducer_override != NULL) { - reduce_value = _PyObject_CallOneArg(self->reducer_override, obj); + reduce_value = PyObject_CallOneArg(self->reducer_override, obj); if (reduce_value == NULL) { goto error; } diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index 80bb44dce9092d..2aed79e14c4b51 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -80,7 +80,7 @@ _enable_gc(int need_to_reenable_gc, PyObject *gc_module) if (need_to_reenable_gc) { PyErr_Fetch(&exctype, &val, &tb); - result = _PyObject_CallMethodNoArgs( + result = PyObject_CallMethodNoArgs( gc_module, _posixsubprocessstate_global->enable); if (exctype != NULL) { PyErr_Restore(exctype, val, tb); @@ -657,7 +657,7 @@ subprocess_fork_exec(PyObject* self, PyObject *args) gc_module = PyImport_ImportModule("gc"); if (gc_module == NULL) return NULL; - result = _PyObject_CallMethodNoArgs( + result = PyObject_CallMethodNoArgs( gc_module, _posixsubprocessstate_global->isenabled); if (result == NULL) { Py_DECREF(gc_module); @@ -669,7 +669,7 @@ subprocess_fork_exec(PyObject* self, PyObject *args) Py_DECREF(gc_module); return NULL; } - result = _PyObject_CallMethodNoArgs( + result = PyObject_CallMethodNoArgs( gc_module, _posixsubprocessstate_global->disable); if (result == NULL) { Py_DECREF(gc_module); diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c index 1f4bf74fc7a1e2..f0fdb0382c5d35 100644 --- a/Modules/_randommodule.c +++ b/Modules/_randommodule.c @@ -287,7 +287,7 @@ random_seed(RandomObject *self, PyObject *arg) /* Calling int.__abs__() prevents calling arg.__abs__(), which might return an invalid value. See issue #31478. */ args[0] = arg; - n = _PyObject_Vectorcall(_randomstate_global->Long___abs__, args, 0, + n = PyObject_Vectorcall(_randomstate_global->Long___abs__, args, 0, NULL); } else { diff --git a/Modules/_sqlite/cache.c b/Modules/_sqlite/cache.c index 7552d1b145394b..758fc022f78108 100644 --- a/Modules/_sqlite/cache.c +++ b/Modules/_sqlite/cache.c @@ -183,7 +183,7 @@ PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* key) } } - /* We cannot replace this by _PyObject_CallOneArg() since + /* We cannot replace this by PyObject_CallOneArg() since * PyObject_CallFunction() has a special case when using a * single tuple as argument. */ data = PyObject_CallFunction(self->factory, "O", key); diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 64051669185ba6..697295da9ce397 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -308,7 +308,7 @@ PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, factory = (PyObject*)&pysqlite_CursorType; } - cursor = _PyObject_CallOneArg(factory, (PyObject *)self); + cursor = PyObject_CallOneArg(factory, (PyObject *)self); if (cursor == NULL) return NULL; if (!PyObject_TypeCheck(cursor, &pysqlite_CursorType)) { @@ -975,7 +975,7 @@ static void _trace_callback(void* user_arg, const char* statement_string) py_statement = PyUnicode_DecodeUTF8(statement_string, strlen(statement_string), "replace"); if (py_statement) { - ret = _PyObject_CallOneArg((PyObject*)user_arg, py_statement); + ret = PyObject_CallOneArg((PyObject*)user_arg, py_statement); Py_DECREF(py_statement); } @@ -1472,7 +1472,7 @@ pysqlite_connection_iterdump(pysqlite_Connection* self, PyObject* args) goto finally; } - retval = _PyObject_CallOneArg(pyfn_iterdump, (PyObject *)self); + retval = PyObject_CallOneArg(pyfn_iterdump, (PyObject *)self); finally: Py_XDECREF(module); diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 45f5865590d692..2ceeab775c8904 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -266,7 +266,7 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self) item = PyBytes_FromStringAndSize(val_str, nbytes); if (!item) goto error; - converted = _PyObject_CallOneArg(converter, item); + converted = PyObject_CallOneArg(converter, item); Py_DECREF(item); } } else { diff --git a/Modules/_sqlite/microprotocols.c b/Modules/_sqlite/microprotocols.c index 59a5e228454ec4..3414be3894e6d2 100644 --- a/Modules/_sqlite/microprotocols.c +++ b/Modules/_sqlite/microprotocols.c @@ -92,7 +92,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) Py_DECREF(key); if (adapter) { Py_INCREF(adapter); - adapted = _PyObject_CallOneArg(adapter, obj); + adapted = PyObject_CallOneArg(adapter, obj); Py_DECREF(adapter); return adapted; } @@ -105,7 +105,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) return NULL; } if (adapter) { - adapted = _PyObject_CallOneArg(adapter, obj); + adapted = PyObject_CallOneArg(adapter, obj); Py_DECREF(adapter); if (adapted == Py_None) { @@ -124,7 +124,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) return NULL; } if (adapter) { - adapted = _PyObject_CallOneArg(adapter, proto); + adapted = PyObject_CallOneArg(adapter, proto); Py_DECREF(adapter); if (adapted == Py_None) { diff --git a/Modules/_sre.c b/Modules/_sre.c index f4f9d01dfccfdd..112eea07540977 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -1082,7 +1082,7 @@ pattern_subx(PatternObject* self, PyObject* ptemplate, PyObject* string, match = pattern_new_match(self, &state, 1); if (!match) goto error; - item = _PyObject_CallOneArg(filter, match); + item = PyObject_CallOneArg(filter, match); Py_DECREF(match); if (!item) goto error; diff --git a/Modules/_struct.c b/Modules/_struct.c index cc536b46a623ec..0cdfe268e645fb 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -2097,7 +2097,7 @@ cache_struct_converter(PyObject *fmt, PyStructObject **ptr) return 0; } - s_object = _PyObject_CallOneArg(_structmodulestate_global->PyStructType, fmt); + s_object = PyObject_CallOneArg(_structmodulestate_global->PyStructType, fmt); if (s_object != NULL) { if (PyDict_GET_SIZE(cache) >= MAXCACHE) PyDict_Clear(cache); diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 943bee6e21e197..16c62eeb8e7684 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -4851,7 +4851,7 @@ test_pyobject_fastcalldict(PyObject *self, PyObject *args) return NULL; } - return _PyObject_FastCallDict(func, stack, nargs, kwargs); + return PyObject_FastCallDict(func, stack, nargs, kwargs); } @@ -4885,7 +4885,7 @@ test_pyobject_vectorcall(PyObject *self, PyObject *args) PyErr_SetString(PyExc_TypeError, "kwnames must be None or a tuple"); return NULL; } - return _PyObject_Vectorcall(func, stack, nargs, kwnames); + return PyObject_Vectorcall(func, stack, nargs, kwnames); } @@ -5258,7 +5258,7 @@ meth_fastcall_keywords(PyObject* self, PyObject* const* args, if (pyargs == NULL) { return NULL; } - PyObject *pykwargs = _PyObject_Vectorcall((PyObject*)&PyDict_Type, + PyObject *pykwargs = PyObject_Vectorcall((PyObject*)&PyDict_Type, args + nargs, 0, kwargs); return Py_BuildValue("NNN", _null_to_none(self), pyargs, pykwargs); } @@ -6138,7 +6138,7 @@ static PyTypeObject MethodDescriptorBase_Type = { .tp_call = PyVectorcall_Call, .tp_vectorcall_offset = offsetof(MethodDescriptorObject, vectorcall), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_METHOD_DESCRIPTOR | _Py_TPFLAGS_HAVE_VECTORCALL, + Py_TPFLAGS_METHOD_DESCRIPTOR | Py_TPFLAGS_HAVE_VECTORCALL, .tp_descr_get = func_descr_get, }; @@ -6177,7 +6177,7 @@ static PyTypeObject MethodDescriptor2_Type = { .tp_new = MethodDescriptor2_new, .tp_call = PyVectorcall_Call, .tp_vectorcall_offset = offsetof(MethodDescriptor2Object, vectorcall), - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | _Py_TPFLAGS_HAVE_VECTORCALL, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_VECTORCALL, }; PyDoc_STRVAR(heapgctype__doc__, diff --git a/Modules/_xxtestfuzz/fuzzer.c b/Modules/_xxtestfuzz/fuzzer.c index dae1eaeabd000b..74ba819b8b50be 100644 --- a/Modules/_xxtestfuzz/fuzzer.c +++ b/Modules/_xxtestfuzz/fuzzer.c @@ -104,7 +104,7 @@ static int fuzz_json_loads(const char* data, size_t size) { if (input_bytes == NULL) { return 0; } - PyObject* parsed = _PyObject_CallOneArg(json_loads_method, input_bytes); + PyObject* parsed = PyObject_CallOneArg(json_loads_method, input_bytes); if (parsed == NULL) { /* Ignore ValueError as the fuzzer will more than likely generate some invalid json and values */ @@ -263,7 +263,7 @@ static int fuzz_sre_match(const char* data, size_t size) { PyObject* pattern = compiled_patterns[idx]; PyObject* match_callable = PyObject_GetAttrString(pattern, "match"); - PyObject* matches = _PyObject_CallOneArg(match_callable, to_match); + PyObject* matches = PyObject_CallOneArg(match_callable, to_match); Py_XDECREF(matches); Py_DECREF(match_callable); diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h index 7ed836598b36d8..8f6f880cadf71e 100644 --- a/Modules/cjkcodecs/cjkcodecs.h +++ b/Modules/cjkcodecs/cjkcodecs.h @@ -291,7 +291,7 @@ getcodec(PyObject *self, PyObject *encoding) if (codecobj == NULL) return NULL; - r = _PyObject_CallOneArg(cofunc, codecobj); + r = PyObject_CallOneArg(cofunc, codecobj); Py_DECREF(codecobj); return r; diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index f24ec933508f14..c798fd6dade11b 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -92,7 +92,7 @@ call_error_callback(PyObject *errors, PyObject *exc) if (cb == NULL) return NULL; - r = _PyObject_CallOneArg(cb, exc); + r = PyObject_CallOneArg(cb, exc); Py_DECREF(cb); return r; } diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index b11ae842e2295a..ed121b4ea6753e 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -875,7 +875,7 @@ handle_weakrefs(PyGC_Head *unreachable, PyGC_Head *old) _PyObject_ASSERT(op, callback != NULL); /* copy-paste of weakrefobject.c's handle_callback() */ - temp = _PyObject_CallOneArg(callback, (PyObject *)wr); + temp = PyObject_CallOneArg(callback, (PyObject *)wr); if (temp == NULL) PyErr_WriteUnraisable(callback); else diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 0cb472966d1f95..6b32b555c32323 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -134,7 +134,7 @@ groupby_step(groupbyobject *gbo) newkey = newvalue; Py_INCREF(newvalue); } else { - newkey = _PyObject_CallOneArg(gbo->keyfunc, newvalue); + newkey = PyObject_CallOneArg(gbo->keyfunc, newvalue); if (newkey == NULL) { Py_DECREF(newvalue); return -1; @@ -1219,7 +1219,7 @@ dropwhile_next(dropwhileobject *lz) if (lz->start == 1) return item; - good = _PyObject_CallOneArg(lz->func, item); + good = PyObject_CallOneArg(lz->func, item); if (good == NULL) { Py_DECREF(item); return NULL; @@ -1382,7 +1382,7 @@ takewhile_next(takewhileobject *lz) if (item == NULL) return NULL; - good = _PyObject_CallOneArg(lz->func, item); + good = PyObject_CallOneArg(lz->func, item); if (good == NULL) { Py_DECREF(item); return NULL; @@ -3918,7 +3918,7 @@ filterfalse_next(filterfalseobject *lz) ok = PyObject_IsTrue(item); } else { PyObject *good; - good = _PyObject_CallOneArg(lz->func, item); + good = PyObject_CallOneArg(lz->func, item); if (good == NULL) { Py_DECREF(item); return NULL; diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index 90167342fee50a..a7f8b5086bbfac 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -119,7 +119,7 @@ set_error(xmlparseobject *self, enum XML_Error code) XML_ErrorString(code), lineno, column); if (buffer == NULL) return NULL; - err = _PyObject_CallOneArg(ErrorObject, buffer); + err = PyObject_CallOneArg(ErrorObject, buffer); Py_DECREF(buffer); if ( err != NULL && set_error_attr(err, "code", code) diff --git a/Objects/abstract.c b/Objects/abstract.c index dc8ba10762de6d..c285a6dfd63f10 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)) { @@ -2499,7 +2499,7 @@ object_isinstance(PyThreadState *tstate, PyObject *inst, PyObject *cls) Py_DECREF(checker); return ok; } - PyObject *res = _PyObject_CallOneArg(checker, inst); + PyObject *res = PyObject_CallOneArg(checker, inst); _Py_LeaveRecursiveCall(tstate); Py_DECREF(checker); if (res != NULL) { @@ -2582,7 +2582,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 c9bf11bba1dd23..300f6a32cd15af 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 f9823f18e8699e..1eaafcd08cb58a 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2274,7 +2274,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 0f8cb5aa246b08..259dce7e22d8bd 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_FastCallDict() 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_FastCallDict(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 db53f04862cd6b..36bccb86485185 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 342b993e090390..fa7f5b9910d146 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -452,7 +452,7 @@ classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args, if (bound == NULL) { return NULL; } - PyObject *res = _PyObject_FastCallDict(bound, _PyTuple_ITEMS(args)+1, + PyObject *res = PyObject_FastCallDict(bound, _PyTuple_ITEMS(args)+1, argc-1, kwds); Py_DECREF(bound); return res; @@ -672,7 +672,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 87f88abbe53bd9..5dccbd135e2ae8 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -2117,7 +2117,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 3ec5a00f30f6a8..52b21154a96d90 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -136,7 +136,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 4fc412b43f7a3e..dfaead4f0667db 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -1511,7 +1511,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 b6ffc2a184c99b..e42caee1e74570 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 c5fe9999af26e2..c837cb08ca3c81 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 bc8425cae63e12..1510ca052ff91c 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2257,7 +2257,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 be9301f85162c8..461f2723949fed 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -5578,7 +5578,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 66920eaf947abd..e24d94e93c9a74 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -1962,7 +1962,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; @@ -2001,7 +2001,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 6a37238d86d8d4..29ce319de7036f 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 03c7381311aa14..f281d898f484ea 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -736,7 +736,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); } _Py_IDENTIFIER(__name__); mod_name = _PyDict_GetItemId(m->md_dict, &PyId___name__); diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 720363410ceb1e..b22130b4771f80 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1463,7 +1463,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); @@ -3664,7 +3664,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 */ @@ -5194,17 +5194,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); } @@ -5280,14 +5280,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); } @@ -6607,7 +6607,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; } @@ -7566,7 +7566,7 @@ init_subclass(PyTypeObject *type, PyObject *kwds) } - result = _PyObject_FastCallDict(func, NULL, 0, kwds); + result = PyObject_FastCallDict(func, NULL, 0, kwds); Py_DECREF(func); if (result == NULL) { return -1; diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 1ec2accdb09f20..6a6f1241631b0f 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -4255,7 +4255,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)) { @@ -4359,7 +4359,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)) { @@ -6806,7 +6806,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)) { @@ -8788,7 +8788,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 bf79e0c7ecbcc9..cd8412fd3dc05a 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -931,7 +931,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); diff --git a/Python/_warnings.c b/Python/_warnings.c index b8585d204787db..e588d060582f1d 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -592,7 +592,7 @@ call_show_warning(PyObject *category, PyObject *text, PyObject *message, if (msg == NULL) goto error; - res = _PyObject_CallOneArg(show_fn, msg); + res = PyObject_CallOneArg(show_fn, msg); Py_DECREF(show_fn); Py_DECREF(msg); @@ -653,7 +653,7 @@ warn_explicit(PyObject *category, PyObject *message, } else { text = message; - message = _PyObject_CallOneArg(category, message); + message = PyObject_CallOneArg(category, message); if (message == NULL) goto cleanup; } @@ -998,7 +998,7 @@ get_source_line(PyObject *module_globals, int lineno) return NULL; } /* Call get_source() to get the source code. */ - source = _PyObject_CallOneArg(get_source, module_name); + source = PyObject_CallOneArg(get_source, module_name); Py_DECREF(get_source); Py_DECREF(module_name); if (!source) { @@ -1285,7 +1285,7 @@ _PyErr_WarnUnawaitedCoroutine(PyObject *coro) int warned = 0; PyObject *fn = get_warnings_attr(&PyId__warn_unawaited_coroutine, 1); if (fn) { - PyObject *res = _PyObject_CallOneArg(fn, coro); + PyObject *res = PyObject_CallOneArg(fn, coro); Py_DECREF(fn); if (res || PyErr_ExceptionMatches(PyExc_RuntimeWarning)) { warned = 1; diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 34267685be2f1f..8dbde32d91b46c 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -55,7 +55,7 @@ update_bases(PyObject *bases, PyObject *const *args, Py_ssize_t nargs) } continue; } - new_base = _PyObject_CallOneArg(meth, bases); + new_base = PyObject_CallOneArg(meth, bases); Py_DECREF(meth); if (!new_base) { goto error; @@ -202,7 +202,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs, } else { PyObject *pargs[2] = {name, bases}; - ns = _PyObject_FastCallDict(prep, pargs, 2, mkw); + ns = PyObject_FastCallDict(prep, pargs, 2, mkw); Py_DECREF(prep); } if (ns == NULL) { @@ -228,7 +228,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs, } } PyObject *margs[3] = {name, bases, ns}; - cls = _PyObject_FastCallDict(meta, margs, 3, mkw); + cls = PyObject_FastCallDict(meta, margs, 3, mkw); if (cls != NULL && PyType_Check(cls) && PyCell_Check(cell)) { PyObject *cell_cls = PyCell_GET(cell); if (cell_cls != cls) { @@ -488,7 +488,7 @@ builtin_breakpoint(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb } Py_INCREF(hook); - PyObject *retval = _PyObject_Vectorcall(hook, args, nargs, keywords); + PyObject *retval = PyObject_Vectorcall(hook, args, nargs, keywords); Py_DECREF(hook); return retval; } @@ -574,7 +574,7 @@ filter_next(filterobject *lz) ok = PyObject_IsTrue(item); } else { PyObject *good; - good = _PyObject_CallOneArg(lz->func, item); + good = PyObject_CallOneArg(lz->func, item); if (good == NULL) { Py_DECREF(item); return NULL; @@ -1625,7 +1625,7 @@ min_max(PyObject *args, PyObject *kwds, int op) while (( item = PyIter_Next(it) )) { /* get the value from the key function */ if (keyfunc != NULL) { - val = _PyObject_CallOneArg(keyfunc, item); + val = PyObject_CallOneArg(keyfunc, item); if (val == NULL) goto Fail_it_item; } @@ -2172,7 +2172,7 @@ builtin_round_impl(PyObject *module, PyObject *number, PyObject *ndigits) if (ndigits == Py_None) result = _PyObject_CallNoArg(round); else - result = _PyObject_CallOneArg(round, ndigits); + result = PyObject_CallOneArg(round, ndigits); Py_DECREF(round); return result; } @@ -2228,7 +2228,7 @@ builtin_sorted(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject } assert(nargs >= 1); - v = _PyObject_Vectorcall(callable, args + 1, nargs - 1, kwnames); + v = PyObject_Vectorcall(callable, args + 1, nargs - 1, kwnames); Py_DECREF(callable); if (v == NULL) { Py_DECREF(newlist); diff --git a/Python/ceval.c b/Python/ceval.c index bd9454b2812ddf..17b00e4529d18c 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1880,7 +1880,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) Py_DECREF(value); goto error; } - res = _PyObject_CallOneArg(hook, value); + res = PyObject_CallOneArg(hook, value); Py_DECREF(value); if (res == NULL) goto error; @@ -3235,7 +3235,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) assert(!PyLong_Check(exc)); exit_func = PEEK(7); PyObject *stack[4] = {NULL, exc, val, tb}; - res = _PyObject_Vectorcall(exit_func, stack + 1, + res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; @@ -4808,7 +4808,7 @@ trace_call_function(PyThreadState *tstate, { PyObject *x; if (PyCFunction_Check(func)) { - C_TRACE(x, _PyObject_Vectorcall(func, args, nargs, kwnames)); + C_TRACE(x, PyObject_Vectorcall(func, args, nargs, kwnames)); return x; } else if (Py_TYPE(func) == &PyMethodDescr_Type && nargs > 0) { @@ -4824,13 +4824,13 @@ trace_call_function(PyThreadState *tstate, if (func == NULL) { return NULL; } - C_TRACE(x, _PyObject_Vectorcall(func, + C_TRACE(x, PyObject_Vectorcall(func, args+1, nargs-1, kwnames)); Py_DECREF(func); return x; } - return _PyObject_Vectorcall(func, args, nargs | PY_VECTORCALL_ARGUMENTS_OFFSET, kwnames); + return PyObject_Vectorcall(func, args, nargs | PY_VECTORCALL_ARGUMENTS_OFFSET, kwnames); } /* Issue #29227: Inline call_function() into _PyEval_EvalFrameDefault() @@ -4849,7 +4849,7 @@ call_function(PyThreadState *tstate, PyObject ***pp_stack, Py_ssize_t oparg, PyO x = trace_call_function(tstate, func, stack, nargs, kwnames); } else { - x = _PyObject_Vectorcall(func, stack, nargs | PY_VECTORCALL_ARGUMENTS_OFFSET, kwnames); + x = PyObject_Vectorcall(func, stack, nargs | PY_VECTORCALL_ARGUMENTS_OFFSET, kwnames); } assert((x != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); diff --git a/Python/codecs.c b/Python/codecs.c index 08e9b916f201d5..bfd418e312e573 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -147,7 +147,7 @@ PyObject *_PyCodec_Lookup(const char *encoding) func = PyList_GetItem(interp->codec_search_path, i); if (func == NULL) goto onError; - result = _PyObject_CallOneArg(func, v); + result = PyObject_CallOneArg(func, v); if (result == NULL) goto onError; if (result == Py_None) { @@ -317,7 +317,7 @@ PyObject *codec_getstreamcodec(const char *encoding, if (errors != NULL) streamcodec = PyObject_CallFunction(codeccls, "Os", stream, errors); else - streamcodec = _PyObject_CallOneArg(codeccls, stream); + streamcodec = PyObject_CallOneArg(codeccls, stream); Py_DECREF(codecs); return streamcodec; } diff --git a/Python/errors.c b/Python/errors.c index d65707e7f97f59..c55bb9d53b8c36 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -93,7 +93,7 @@ _PyErr_CreateException(PyObject *exception, PyObject *value) return PyObject_Call(exception, value, NULL); } else { - return _PyObject_CallOneArg(exception, value); + return PyObject_CallOneArg(exception, value); } } @@ -901,7 +901,7 @@ PyErr_SetImportErrorSubclass(PyObject *exception, PyObject *msg, goto done; } - error = _PyObject_FastCallDict(exception, &msg, 1, kwargs); + error = PyObject_FastCallDict(exception, &msg, 1, kwargs); if (error != NULL) { _PyErr_SetObject(tstate, (PyObject *)Py_TYPE(error), error); Py_DECREF(error); @@ -1418,7 +1418,7 @@ _PyErr_WriteUnraisableMsg(const char *err_msg_str, PyObject *obj) goto default_hook; } - PyObject *res = _PyObject_CallOneArg(hook, hook_args); + PyObject *res = PyObject_CallOneArg(hook, hook_args); Py_DECREF(hook_args); if (res != NULL) { Py_DECREF(res); diff --git a/Python/import.c b/Python/import.c index 045b6d0a9bf6f9..92136581945e4a 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1203,7 +1203,7 @@ get_path_importer(PyThreadState *tstate, PyObject *path_importer_cache, PyObject *hook = PyList_GetItem(path_hooks, j); if (hook == NULL) return NULL; - importer = _PyObject_CallOneArg(hook, p); + importer = PyObject_CallOneArg(hook, p); if (importer != NULL) break; diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 9f866a2a3d2fa0..8900ecf2752285 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -519,7 +519,7 @@ sys_breakpointhook(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb return NULL; } PyMem_RawFree(envar); - PyObject *retval = _PyObject_Vectorcall(hook, args, nargs, keywords); + PyObject *retval = PyObject_Vectorcall(hook, args, nargs, keywords); Py_DECREF(hook); return retval; From 116d0d0fb58a3141ed09c0f0e312784bbaef17a9 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 26 Nov 2019 14:24:24 +0100 Subject: [PATCH 02/10] Fix up formatting in docs --- Doc/c-api/call.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/c-api/call.rst b/Doc/c-api/call.rst index 6c62a6832f93b9..c204421204ddba 100644 --- a/Doc/c-api/call.rst +++ b/Doc/c-api/call.rst @@ -185,7 +185,7 @@ please see individual documentation for details. +------------------------------------------+------------------+--------------------+---------------+ | :c:func:`PyObject_CallNoArgs` | ``PyObject *`` | --- | --- | +------------------------------------------+------------------+--------------------+---------------+ -| :c:func:`PyObject_CallOneArg` | ``PyObject *`` | 1 object | --- | +| :c:func:`PyObject_CallOneArg` | ``PyObject *`` | 1 object | --- | +------------------------------------------+------------------+--------------------+---------------+ | :c:func:`PyObject_CallObject` | ``PyObject *`` | tuple/``NULL`` | --- | +------------------------------------------+------------------+--------------------+---------------+ @@ -197,15 +197,15 @@ please see individual documentation for details. +------------------------------------------+------------------+--------------------+---------------+ | :c:func:`PyObject_CallMethodObjArgs` | obj + name | variadic | --- | +------------------------------------------+------------------+--------------------+---------------+ -| :c:func:`PyObject_CallMethodNoArgs` | obj + name | --- | --- | +| :c:func:`PyObject_CallMethodNoArgs` | obj + name | --- | --- | +------------------------------------------+------------------+--------------------+---------------+ -| :c:func:`PyObject_CallMethodOneArg` | obj + name | 1 object | --- | +| :c:func:`PyObject_CallMethodOneArg` | obj + name | 1 object | --- | +------------------------------------------+------------------+--------------------+---------------+ -| :c:func:`PyObject_Vectorcall` | ``PyObject *`` | vectorcall | vectorcall | +| :c:func:`PyObject_Vectorcall` | ``PyObject *`` | vectorcall | vectorcall | +------------------------------------------+------------------+--------------------+---------------+ -| :c:func:`PyObject_FastCallDict` | ``PyObject *`` | vectorcall | dict/``NULL`` | +| :c:func:`PyObject_FastCallDict` | ``PyObject *`` | vectorcall | dict/``NULL`` | +------------------------------------------+------------------+--------------------+---------------+ -| :c:func:`PyObject_VectorcallMethod` | arg + name | vectorcall | vectorcall | +| :c:func:`PyObject_VectorcallMethod` | arg + name | vectorcall | vectorcall | +------------------------------------------+------------------+--------------------+---------------+ From f0c005f879e71442cf5c9a52e75b38ff9f0fc823 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 19 Nov 2019 13:42:29 +0100 Subject: [PATCH 03/10] Add backcompat defines and move non-limited API declaration to cpython/ This partially reverts commit 2ff58a24e8a1c7e290d025d69ebaea0bbead3b8c which added PyObject_CallNoArgs to the 3.9+ stable ABI. This should not be done; there are enough other call APIs in the stable ABI to choose from. --- Include/abstract.h | 6 ------ Include/cpython/abstract.h | 11 +++++++++++ Include/object.h | 2 ++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Include/abstract.h b/Include/abstract.h index bb51c668ac6983..c63127d6d6ead9 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -141,12 +141,6 @@ extern "C" { #endif -#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000 -/* Call a callable Python object without any arguments */ -PyAPI_FUNC(PyObject *) PyObject_CallNoArgs(PyObject *func); -#endif - - /* Call a callable Python object 'callable' with arguments given by the tuple 'args' and keywords arguments given by the dictionary 'kwargs'. diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index cd13f98590d59f..e9bda3fce50884 100644 --- a/Include/cpython/abstract.h +++ b/Include/cpython/abstract.h @@ -120,6 +120,14 @@ PyObject_Vectorcall(PyObject *callable, PyObject *const *args, return _PyObject_VectorcallTstate(tstate, callable, args, nargsf, kwnames); } +// Backwards compatibility aliases for API that was provisional in Python 3.8 +#define _PyObject_Vectorcall PyObject_Vectorcall +#define _PyObject_VectorcallMethod PyObject_VectorcallMethod +#define _PyObject_FastCallDict PyObject_FastCallDict +#define _PyVectorcall_Function PyVectorcall_Function +#define _PyObject_CallOneArg PyObject_CallOneArg +#define _PyObject_CallMethodNoArgs PyObject_CallMethodNoArgs +#define _PyObject_CallMethodOneArg PyObject_CallMethodOneArg /* Same as PyObject_Vectorcall except that keyword arguments are passed as dict, which may be NULL if there are no keyword arguments. */ @@ -182,6 +190,9 @@ PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg) 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); } +/* Call a callable Python object without any arguments */ +PyAPI_FUNC(PyObject *) PyObject_CallNoArgs(PyObject *func); + /* Like PyObject_CallMethod(), but expect a _Py_Identifier* as the method name. */ PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *obj, diff --git a/Include/object.h b/Include/object.h index 3834909b915dc2..8d8215310f9e00 100644 --- a/Include/object.h +++ b/Include/object.h @@ -291,6 +291,8 @@ given type object has a specified feature. /* Set if the type implements the vectorcall protocol (PEP 590) */ #ifndef Py_LIMITED_API #define Py_TPFLAGS_HAVE_VECTORCALL (1UL << 11) +// Backwards compatibility alias for API that was provisional in Python 3.8 +#define _Py_TPFLAGS_HAVE_VECTORCALL Py_TPFLAGS_HAVE_VECTORCALL #endif /* Set if the type is 'ready' -- fully initialized */ From d94898305952aa71b2166db4594001aee45e5330 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 26 Nov 2019 13:19:42 +0100 Subject: [PATCH 04/10] Adjust documentation Mark all newly public functions as added in 3.9. Add a note about the 3.8 provisional names. Add notes on public API. --- Doc/c-api/call.rst | 51 +++++++++++++++++++++++++++---------------- Doc/c-api/typeobj.rst | 8 +------ 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/Doc/c-api/call.rst b/Doc/c-api/call.rst index c204421204ddba..6703ec37fba008 100644 --- a/Doc/c-api/call.rst +++ b/Doc/c-api/call.rst @@ -35,17 +35,11 @@ To call an object, use :c:func:`PyObject_Call` or other The Vectorcall Protocol ----------------------- -.. versionadded:: 3.8 +.. versionadded:: 3.9 The vectorcall protocol was introduced in :pep:`590` as an additional protocol for making calls more efficient. -.. warning:: - - The vectorcall API is provisional and expected to become public in - Python 3.9, with a different names and, possibly, changed semantics. - If you use the it, plan for updating your code for Python 3.9. - As rule of thumb, CPython will prefer the vectorcall for internal calls if the callable supports it. However, this is not a hard rule. Additionally, some third-party extensions use *tp_call* directly @@ -110,6 +104,17 @@ function as with any other callable. :c:func:`PyObject_Vectorcall` will usually be most efficient. +.. note:: + + In CPython 3.8, the vectorcall API and related functions were available + provisionally under names with a leading underscore: + ``_PyObject_Vectorcall``, ``_Py_TPFLAGS_HAVE_VECTORCALL``, + ``_PyObject_VectorcallMethod``, ``_PyObject_FastCallDict``, + ``_PyVectorcall_Function``, ``_PyObject_CallOneArg``, + ``_PyObject_CallMethodNoArgs``, ``_PyObject_CallMethodOneArg``. + These are still defined as aliases of the non-underscored names. + + Recursion Control ................. @@ -137,6 +142,8 @@ Vectorcall Support API However, the function ``PyVectorcall_NARGS`` should be used to allow for future extensions. + This function is not part of the `limited API `_. + .. versionadded:: 3.8 .. c:function:: vectorcallfunc PyVectorcall_Function(PyObject *op) @@ -149,6 +156,8 @@ Vectorcall Support API This is mostly useful to check whether or not *op* supports vectorcall, which can be done by checking ``PyVectorcall_Function(op) != NULL``. + This function is not part of the `limited API `_. + .. versionadded:: 3.8 .. c:function:: PyObject* PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict) @@ -161,6 +170,8 @@ Vectorcall Support API It does not check the :const:`Py_TPFLAGS_HAVE_VECTORCALL` flag and it does not fall back to ``tp_call``. + This function is not part of the `limited API `_. + .. versionadded:: 3.8 @@ -232,6 +243,8 @@ please see individual documentation for details. Return the result of the call on success, or raise an exception and return *NULL* on failure. + This function is not part of the `limited API `_. + .. versionadded:: 3.9 @@ -243,6 +256,8 @@ please see individual documentation for details. Return the result of the call on success, or raise an exception and return *NULL* on failure. + This function is not part of the `limited API `_. + .. versionadded:: 3.9 @@ -328,6 +343,8 @@ please see individual documentation for details. Return the result of the call on success, or raise an exception and return *NULL* on failure. + This function is not part of the `limited API `_. + .. versionadded:: 3.9 @@ -340,6 +357,8 @@ please see individual documentation for details. Return the result of the call on success, or raise an exception and return *NULL* on failure. + This function is not part of the `limited API `_. + .. versionadded:: 3.9 @@ -353,13 +372,9 @@ please see individual documentation for details. Return the result of the call on success, or raise an exception and return *NULL* on failure. - .. note:: + This function is not part of the `limited API `_. - This function is provisional and expected to become public in Python 3.9, - with a different name and, possibly, changed semantics. - If you use the function, plan for updating your code for Python 3.9. - - .. versionadded:: 3.8 + .. versionadded:: 3.9 .. c:function:: PyObject* PyObject_FastCallDict(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwdict) @@ -373,13 +388,9 @@ please see individual documentation for details. already has a dictionary ready to use for the keyword arguments, but not a tuple for the positional arguments. - .. note:: - - This function is provisional and expected to become public in Python 3.9, - with a different name and, possibly, changed semantics. - If you use the function, plan for updating your code for Python 3.9. + This function is not part of the `limited API `_. - .. versionadded:: 3.8 + .. versionadded:: 3.9 .. c:function:: PyObject* PyObject_VectorcallMethod(PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames) @@ -399,6 +410,8 @@ please see individual documentation for details. Return the result of the call on success, or raise an exception and return *NULL* on failure. + This function is not part of the `limited API `_. + .. versionadded:: 3.9 diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index be908126946162..bda726144d13dc 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -1174,13 +1174,7 @@ and :c:type:`PyType_Type` effectively act as defaults.) :c:member:`~PyTypeObject.tp_call` is also inherited. `Heap types`_ do not inherit ``Py_TPFLAGS_HAVE_VECTORCALL``. - .. note:: - - This flag is provisional and expected to become public in Python 3.9, - with a different name and, possibly, changed semantics. - If you use vectorcall, plan for updating your code for Python 3.9. - - .. versionadded:: 3.8 + .. versionadded:: 3.9 .. c:member:: const char* PyTypeObject.tp_doc From 5e340bf8fe966b6d66a09ec9691f4fd1b75a5bdb Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 7 Jan 2020 13:47:24 +0100 Subject: [PATCH 05/10] Add a NEWS entry --- Misc/NEWS.d/next/C API/2020-01-07-13-46-40.bpo-39245.G7wog6.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/C API/2020-01-07-13-46-40.bpo-39245.G7wog6.rst diff --git a/Misc/NEWS.d/next/C API/2020-01-07-13-46-40.bpo-39245.G7wog6.rst b/Misc/NEWS.d/next/C API/2020-01-07-13-46-40.bpo-39245.G7wog6.rst new file mode 100644 index 00000000000000..4578ef87757cd6 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2020-01-07-13-46-40.bpo-39245.G7wog6.rst @@ -0,0 +1 @@ +The Vectorcall API (PEP 590) was made public. From 60a8833584767d2651579deddaf594401f2d18fa Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Wed, 8 Jan 2020 13:34:37 +0100 Subject: [PATCH 06/10] Put PyObject_CallNoArgs back in the limited API --- Doc/c-api/call.rst | 2 -- Include/abstract.h | 6 ++++++ Include/cpython/abstract.h | 4 +--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Doc/c-api/call.rst b/Doc/c-api/call.rst index 6703ec37fba008..44f1b7323ff6d1 100644 --- a/Doc/c-api/call.rst +++ b/Doc/c-api/call.rst @@ -243,8 +243,6 @@ please see individual documentation for details. Return the result of the call on success, or raise an exception and return *NULL* on failure. - This function is not part of the `limited API `_. - .. versionadded:: 3.9 diff --git a/Include/abstract.h b/Include/abstract.h index c63127d6d6ead9..bb51c668ac6983 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -141,6 +141,12 @@ extern "C" { #endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000 +/* Call a callable Python object without any arguments */ +PyAPI_FUNC(PyObject *) PyObject_CallNoArgs(PyObject *func); +#endif + + /* Call a callable Python object 'callable' with arguments given by the tuple 'args' and keywords arguments given by the dictionary 'kwargs'. diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index e9bda3fce50884..017a4ffd38973b 100644 --- a/Include/cpython/abstract.h +++ b/Include/cpython/abstract.h @@ -120,6 +120,7 @@ PyObject_Vectorcall(PyObject *callable, PyObject *const *args, return _PyObject_VectorcallTstate(tstate, callable, args, nargsf, kwnames); } + // Backwards compatibility aliases for API that was provisional in Python 3.8 #define _PyObject_Vectorcall PyObject_Vectorcall #define _PyObject_VectorcallMethod PyObject_VectorcallMethod @@ -190,9 +191,6 @@ PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg) 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); } -/* Call a callable Python object without any arguments */ -PyAPI_FUNC(PyObject *) PyObject_CallNoArgs(PyObject *func); - /* Like PyObject_CallMethod(), but expect a _Py_Identifier* as the method name. */ PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *obj, From 29a8331d91f42390106d44c9c78e534c10cb67fd Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Thu, 30 Jan 2020 13:03:22 +0100 Subject: [PATCH 07/10] Revert "update usage of the renamed functions" --- Include/cpython/abstract.h | 12 ++++----- Lib/test/test_call.py | 6 ++--- Misc/NEWS.d/3.9.0a1.rst | 8 +++--- Modules/_asynciomodule.c | 22 ++++++++-------- Modules/_collectionsmodule.c | 2 +- Modules/_csv.c | 6 ++--- Modules/_ctypes/callproc.c | 8 +++--- Modules/_elementtree.c | 16 ++++++------ Modules/_functoolsmodule.c | 4 +-- Modules/_io/bufferedio.c | 30 ++++++++++----------- Modules/_io/iobase.c | 16 ++++++------ Modules/_io/stringio.c | 2 +- Modules/_io/textio.c | 42 +++++++++++++++--------------- Modules/_json.c | 12 ++++----- Modules/_operator.c | 2 +- Modules/_pickle.c | 10 +++---- Modules/_posixsubprocess.c | 6 ++--- Modules/_randommodule.c | 2 +- Modules/_sqlite/cache.c | 2 +- Modules/_sqlite/connection.c | 6 ++--- Modules/_sqlite/cursor.c | 2 +- Modules/_sqlite/microprotocols.c | 6 ++--- Modules/_sre.c | 2 +- Modules/_struct.c | 2 +- Modules/_testcapimodule.c | 10 +++---- Modules/_xxtestfuzz/fuzzer.c | 4 +-- Modules/cjkcodecs/cjkcodecs.h | 2 +- Modules/cjkcodecs/multibytecodec.c | 2 +- Modules/gcmodule.c | 2 +- Modules/itertoolsmodule.c | 8 +++--- Modules/pyexpat.c | 2 +- Objects/abstract.c | 8 +++--- Objects/bytearrayobject.c | 4 +-- Objects/bytesobject.c | 2 +- Objects/call.c | 14 +++++----- Objects/classobject.c | 2 +- Objects/descrobject.c | 8 +++--- Objects/dictobject.c | 2 +- Objects/fileobject.c | 2 +- Objects/floatobject.c | 2 +- Objects/funcobject.c | 2 +- Objects/genobject.c | 8 +++--- Objects/listobject.c | 2 +- Objects/longobject.c | 2 +- Objects/memoryobject.c | 4 +-- Objects/methodobject.c | 2 +- Objects/moduleobject.c | 2 +- Objects/typeobject.c | 20 +++++++------- Objects/unicodeobject.c | 8 +++--- Objects/weakrefobject.c | 2 +- Python/_warnings.c | 8 +++--- Python/bltinmodule.c | 16 ++++++------ Python/ceval.c | 12 ++++----- Python/codecs.c | 4 +-- Python/errors.c | 6 ++--- Python/import.c | 2 +- Python/sysmodule.c | 2 +- 57 files changed, 201 insertions(+), 201 deletions(-) diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index 017a4ffd38973b..ba2cf8dad7605e 100644 --- a/Include/cpython/abstract.h +++ b/Include/cpython/abstract.h @@ -29,7 +29,7 @@ PyAPI_FUNC(PyObject *) _PyStack_AsDict( /* Suggested size (number of positional arguments) for arrays of PyObject* allocated on a C stack to avoid allocating memory on the heap memory. Such array is used to pass positional arguments to call functions of the - PyObject_Vectorcall() family. + _PyObject_Vectorcall() family. The size is chosen to not abuse the C stack and so limit the risk of stack overflow. The size is also chosen to allow using the small stack for most @@ -45,8 +45,8 @@ PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult( /* === Vectorcall protocol (PEP 590) ============================= */ -/* Call callable using tp_call. Arguments are like PyObject_Vectorcall() - or PyObject_FastCallDict() (both forms are supported), +/* Call callable using tp_call. Arguments are like _PyObject_Vectorcall() + or _PyObject_FastCallDict() (both forms are supported), except that nargs is plainly the number of arguments without flags. */ PyAPI_FUNC(PyObject *) _PyObject_MakeTpCall( PyThreadState *tstate, @@ -67,7 +67,7 @@ PyVectorcall_Function(PyObject *callable) { assert(callable != NULL); PyTypeObject *tp = Py_TYPE(callable); - if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL)) { + if (!PyType_HasFeature(tp, _Py_TPFLAGS_HAVE_VECTORCALL)) { return NULL; } assert(PyCallable_Check(callable)); @@ -178,7 +178,7 @@ PyAPI_FUNC(PyObject *) PyObject_VectorcallMethod( static inline PyObject * PyObject_CallMethodNoArgs(PyObject *self, PyObject *name) { - return PyObject_VectorcallMethod(name, &self, + return _PyObject_VectorcallMethod(name, &self, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); } @@ -187,7 +187,7 @@ PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg) { assert(arg != NULL); PyObject *args[2] = {self, arg}; - return PyObject_VectorcallMethod(name, args, + return _PyObject_VectorcallMethod(name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); } diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py index 0249109c45bfad..d178aa4ec2bd2c 100644 --- a/Lib/test/test_call.py +++ b/Lib/test/test_call.py @@ -468,7 +468,7 @@ def test_fastcall(self): self.check_result(result, expected) def test_vectorcall_dict(self): - # Test PyObject_FastCallDict() + # Test _PyObject_FastCallDict() for func, args, expected in self.CALLS_POSARGS: with self.subTest(func=func, args=args): @@ -487,7 +487,7 @@ def test_vectorcall_dict(self): self.check_result(result, expected) def test_vectorcall(self): - # Test PyObject_Vectorcall() + # Test _PyObject_Vectorcall() for func, args, expected in self.CALLS_POSARGS: with self.subTest(func=func, args=args): @@ -594,7 +594,7 @@ def test_vectorcall(self): # 1. vectorcall using PyVectorcall_Call() # (only for objects that support vectorcall directly) # 2. normal call - # 3. vectorcall using PyObject_Vectorcall() + # 3. vectorcall using _PyObject_Vectorcall() # 4. call as bound method # 5. call using functools.partial diff --git a/Misc/NEWS.d/3.9.0a1.rst b/Misc/NEWS.d/3.9.0a1.rst index f822331401403d..fb74d3622263d4 100644 --- a/Misc/NEWS.d/3.9.0a1.rst +++ b/Misc/NEWS.d/3.9.0a1.rst @@ -678,7 +678,7 @@ The :keyword:`assert` statement now works properly if the Removed object cache (``free_list``) for bound method objects. Temporary bound method objects are less used than before thanks to the ``LOAD_METHOD`` -opcode and the ``PyObject_VectorcallMethod`` C API. +opcode and the ``_PyObject_VectorcallMethod`` C API. .. @@ -5676,7 +5676,7 @@ Exclude Python-ast.h, ast.h and asdl.h from the limited API. .. nonce: vftT4f .. section: C API -Add new function ``PyObject_CallOneArg`` for calling an object with one +Add new function ``_PyObject_CallOneArg`` for calling an object with one positional argument. .. @@ -5696,8 +5696,8 @@ Add :func:`PyConfig_SetWideStringList` function. .. section: C API Add fast functions for calling methods: -:c:func:`PyObject_VectorcallMethod`, :c:func:`PyObject_CallMethodNoArgs` -and :c:func:`PyObject_CallMethodOneArg`. +:c:func:`_PyObject_VectorcallMethod`, :c:func:`_PyObject_CallMethodNoArgs` +and :c:func:`_PyObject_CallMethodOneArg`. .. diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index fb6e4cf26edeba..70da40a8a3b863 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -142,7 +142,7 @@ _is_coroutine(PyObject *coro) Do this check after 'future_init()'; in case we need to raise an error, __del__ needs a properly initialized object. */ - PyObject *res = PyObject_CallOneArg(asyncio_iscoroutine_func, coro); + PyObject *res = _PyObject_CallOneArg(asyncio_iscoroutine_func, coro); if (res == NULL) { return -1; } @@ -367,7 +367,7 @@ call_soon(PyObject *loop, PyObject *func, PyObject *arg, PyObject *ctx) } stack[nargs] = (PyObject *)ctx; - handle = PyObject_Vectorcall(callable, stack, nargs, context_kwname); + handle = _PyObject_Vectorcall(callable, stack, nargs, context_kwname); Py_DECREF(callable); } @@ -1287,7 +1287,7 @@ static PyObject * _asyncio_Future__repr_info_impl(FutureObj *self) /*[clinic end generated code: output=fa69e901bd176cfb input=f21504d8e2ae1ca2]*/ { - return PyObject_CallOneArg(asyncio_future_repr_info_func, (PyObject *)self); + return _PyObject_CallOneArg(asyncio_future_repr_info_func, (PyObject *)self); } static PyObject * @@ -1363,7 +1363,7 @@ FutureObj_finalize(FutureObj *fut) func = _PyObject_GetAttrId(fut->fut_loop, &PyId_call_exception_handler); if (func != NULL) { - PyObject *res = PyObject_CallOneArg(func, context); + PyObject *res = _PyObject_CallOneArg(func, context); if (res == NULL) { PyErr_WriteUnraisable(func); } @@ -2126,13 +2126,13 @@ _asyncio_Task_current_task_impl(PyTypeObject *type, PyObject *loop) Py_DECREF(current_task_func); return NULL; } - ret = PyObject_CallOneArg(current_task_func, loop); + ret = _PyObject_CallOneArg(current_task_func, loop); Py_DECREF(current_task_func); Py_DECREF(loop); return ret; } else { - ret = PyObject_CallOneArg(current_task_func, loop); + ret = _PyObject_CallOneArg(current_task_func, loop); Py_DECREF(current_task_func); return ret; } @@ -2168,7 +2168,7 @@ _asyncio_Task_all_tasks_impl(PyTypeObject *type, PyObject *loop) return NULL; } - res = PyObject_CallOneArg(all_tasks_func, loop); + res = _PyObject_CallOneArg(all_tasks_func, loop); Py_DECREF(all_tasks_func); return res; } @@ -2181,7 +2181,7 @@ static PyObject * _asyncio_Task__repr_info_impl(TaskObj *self) /*[clinic end generated code: output=6a490eb66d5ba34b input=3c6d051ed3ddec8b]*/ { - return PyObject_CallOneArg(asyncio_task_repr_info_func, (PyObject *)self); + return _PyObject_CallOneArg(asyncio_task_repr_info_func, (PyObject *)self); } /*[clinic input] @@ -2431,7 +2431,7 @@ TaskObj_finalize(TaskObj *task) func = _PyObject_GetAttrId(task->task_loop, &PyId_call_exception_handler); if (func != NULL) { - PyObject *res = PyObject_CallOneArg(func, context); + PyObject *res = _PyObject_CallOneArg(func, context); if (res == NULL) { PyErr_WriteUnraisable(func); } @@ -2571,7 +2571,7 @@ task_set_error_soon(TaskObj *task, PyObject *et, const char *format, ...) return NULL; } - PyObject *e = PyObject_CallOneArg(et, msg); + PyObject *e = _PyObject_CallOneArg(et, msg); Py_DECREF(msg); if (e == NULL) { return NULL; @@ -2841,7 +2841,7 @@ task_step_impl(TaskObj *task, PyObject *exc) PyObject *stack[2]; stack[0] = wrapper; stack[1] = (PyObject *)task->task_context; - res = PyObject_Vectorcall(add_cb, stack, 1, context_kwname); + res = _PyObject_Vectorcall(add_cb, stack, 1, context_kwname); Py_DECREF(add_cb); Py_DECREF(wrapper); if (res == NULL) { diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 2dfe72d1c58eed..1d23973fd05661 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -512,7 +512,7 @@ deque_copy(PyObject *deque, PyObject *Py_UNUSED(ignored)) return NULL; } if (old_deque->maxlen < 0) - result = PyObject_CallOneArg((PyObject *)(Py_TYPE(deque)), deque); + result = _PyObject_CallOneArg((PyObject *)(Py_TYPE(deque)), deque); else result = PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi", deque, old_deque->maxlen, NULL); diff --git a/Modules/_csv.c b/Modules/_csv.c index cf94cf276ce7db..aaf377650c0b2b 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -514,10 +514,10 @@ _call_dialect(PyObject *dialect_inst, PyObject *kwargs) { PyObject *type = (PyObject *)&Dialect_Type; if (dialect_inst) { - return PyObject_FastCallDict(type, &dialect_inst, 1, kwargs); + return _PyObject_FastCallDict(type, &dialect_inst, 1, kwargs); } else { - return PyObject_FastCallDict(type, NULL, 0, kwargs); + return _PyObject_FastCallDict(type, NULL, 0, kwargs); } } @@ -1240,7 +1240,7 @@ csv_writerow(WriterObj *self, PyObject *seq) if (line == NULL) { return NULL; } - result = PyObject_CallOneArg(self->write, line); + result = _PyObject_CallOneArg(self->write, line); Py_DECREF(line); return result; } diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 34a7f6a75c3858..7b13fa041a205c 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -945,7 +945,7 @@ static PyObject *GetResult(PyObject *restype, void *result, PyObject *checker) if (!checker || !retval) return retval; - v = PyObject_CallOneArg(checker, retval); + v = _PyObject_CallOneArg(checker, retval); if (v == NULL) _PyTraceback_Add("GetResult", "_ctypes/callproc.c", __LINE__-2); Py_DECREF(retval); @@ -1138,7 +1138,7 @@ PyObject *_ctypes_callproc(PPROC pProc, if (argtypes && argtype_count > i) { PyObject *v; converter = PyTuple_GET_ITEM(argtypes, i); - v = PyObject_CallOneArg(converter, arg); + v = _PyObject_CallOneArg(converter, arg); if (v == NULL) { _ctypes_extend_error(PyExc_ArgError, "argument %zd: ", i+1); goto cleanup; @@ -1834,7 +1834,7 @@ pointer(PyObject *self, PyObject *arg) typ = PyDict_GetItemWithError(_ctypes_ptrtype_cache, (PyObject *)Py_TYPE(arg)); if (typ) { - return PyObject_CallOneArg(typ, arg); + return _PyObject_CallOneArg(typ, arg); } else if (PyErr_Occurred()) { return NULL; @@ -1842,7 +1842,7 @@ pointer(PyObject *self, PyObject *arg) typ = POINTER(NULL, (PyObject *)Py_TYPE(arg)); if (typ == NULL) return NULL; - result = PyObject_CallOneArg(typ, arg); + result = _PyObject_CallOneArg(typ, arg); Py_DECREF(typ); return result; } diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index a04b295378e4fe..c096eab43ea6a8 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2671,7 +2671,7 @@ treebuilder_append_event(TreeBuilderObject *self, PyObject *action, PyObject *event = PyTuple_Pack(2, action, node); if (event == NULL) return -1; - res = PyObject_CallOneArg(self->events_append, event); + res = _PyObject_CallOneArg(self->events_append, event); Py_DECREF(event); if (res == NULL) return -1; @@ -2837,7 +2837,7 @@ treebuilder_handle_comment(TreeBuilderObject* self, PyObject* text) } if (self->comment_factory) { - comment = PyObject_CallOneArg(self->comment_factory, text); + comment = _PyObject_CallOneArg(self->comment_factory, text); if (!comment) return NULL; @@ -3179,7 +3179,7 @@ expat_set_error(enum XML_Error error_code, Py_ssize_t line, Py_ssize_t column, if (errmsg == NULL) return; - error = PyObject_CallOneArg(st->parseerror_obj, errmsg); + error = _PyObject_CallOneArg(st->parseerror_obj, errmsg); Py_DECREF(errmsg); if (!error) return; @@ -3242,7 +3242,7 @@ expat_default_handler(XMLParserObject* self, const XML_Char* data_in, (TreeBuilderObject*) self->target, value ); else if (self->handle_data) - res = PyObject_CallOneArg(self->handle_data, value); + res = _PyObject_CallOneArg(self->handle_data, value); else res = NULL; Py_XDECREF(res); @@ -3353,7 +3353,7 @@ expat_data_handler(XMLParserObject* self, const XML_Char* data_in, /* shortcut */ res = treebuilder_handle_data((TreeBuilderObject*) self->target, data); else if (self->handle_data) - res = PyObject_CallOneArg(self->handle_data, data); + res = _PyObject_CallOneArg(self->handle_data, data); else res = NULL; @@ -3380,7 +3380,7 @@ expat_end_handler(XMLParserObject* self, const XML_Char* tag_in) else if (self->handle_end) { tag = makeuniversal(self, tag_in); if (tag) { - res = PyObject_CallOneArg(self->handle_end, tag); + res = _PyObject_CallOneArg(self->handle_end, tag); Py_DECREF(tag); } } @@ -3467,7 +3467,7 @@ expat_end_ns_handler(XMLParserObject* self, const XML_Char* prefix_in) if (!prefix) return; - res = PyObject_CallOneArg(self->handle_end_ns, prefix); + res = _PyObject_CallOneArg(self->handle_end_ns, prefix); Py_DECREF(prefix); } @@ -3499,7 +3499,7 @@ expat_comment_handler(XMLParserObject* self, const XML_Char* comment_in) if (!comment) return; - res = PyObject_CallOneArg(self->handle_comment, comment); + res = _PyObject_CallOneArg(self->handle_comment, comment); Py_XDECREF(res); Py_DECREF(comment); } diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 75fa250d55e62f..987087b1ac97ba 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -213,7 +213,7 @@ partial_vectorcall(partialobject *pto, PyObject *const *args, static void partial_setvectorcall(partialobject *pto) { - if (PyVectorcall_Function(pto->fn) == NULL) { + if (_PyVectorcall_Function(pto->fn) == NULL) { /* Don't use vectorcall if the underlying function doesn't support it */ pto->vectorcall = NULL; } @@ -440,7 +440,7 @@ static PyTypeObject partial_type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_HAVE_VECTORCALL, /* tp_flags */ + _Py_TPFLAGS_HAVE_VECTORCALL, /* tp_flags */ partial_doc, /* tp_doc */ (traverseproc)partial_traverse, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 9b2439b6d5e8d8..586e93f25e28f4 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -461,7 +461,7 @@ static PyObject * buffered_simple_flush(buffered *self, PyObject *args) { CHECK_INITIALIZED(self) - return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_flush); + return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_flush); } static int @@ -513,7 +513,7 @@ buffered_close(buffered *self, PyObject *args) } /* flush() will most probably re-take the lock, so drop it first */ LEAVE_BUFFERED(self) - res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); + res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); if (!ENTER_BUFFERED(self)) return NULL; if (res == NULL) @@ -521,7 +521,7 @@ buffered_close(buffered *self, PyObject *args) else Py_DECREF(res); - res = PyObject_CallMethodNoArgs(self->raw, _PyIO_str_close); + res = _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_close); if (self->buffer) { PyMem_Free(self->buffer); @@ -545,7 +545,7 @@ buffered_detach(buffered *self, PyObject *Py_UNUSED(ignored)) { PyObject *raw, *res; CHECK_INITIALIZED(self) - res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); + res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); if (res == NULL) return NULL; Py_DECREF(res); @@ -562,21 +562,21 @@ static PyObject * buffered_seekable(buffered *self, PyObject *Py_UNUSED(ignored)) { CHECK_INITIALIZED(self) - return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_seekable); + return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_seekable); } static PyObject * buffered_readable(buffered *self, PyObject *Py_UNUSED(ignored)) { CHECK_INITIALIZED(self) - return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_readable); + return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_readable); } static PyObject * buffered_writable(buffered *self, PyObject *Py_UNUSED(ignored)) { CHECK_INITIALIZED(self) - return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_writable); + return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_writable); } static PyObject * @@ -599,14 +599,14 @@ static PyObject * buffered_fileno(buffered *self, PyObject *Py_UNUSED(ignored)) { CHECK_INITIALIZED(self) - return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_fileno); + return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_fileno); } static PyObject * buffered_isatty(buffered *self, PyObject *Py_UNUSED(ignored)) { CHECK_INITIALIZED(self) - return PyObject_CallMethodNoArgs(self->raw, _PyIO_str_isatty); + return _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_isatty); } /* Forward decls */ @@ -670,7 +670,7 @@ _buffered_raw_tell(buffered *self) { Py_off_t n; PyObject *res; - res = PyObject_CallMethodNoArgs(self->raw, _PyIO_str_tell); + res = _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_tell); if (res == NULL) return -1; n = PyNumber_AsOff_t(res, PyExc_ValueError); @@ -1323,7 +1323,7 @@ _io__Buffered_truncate_impl(buffered *self, PyObject *pos) goto end; Py_CLEAR(res); } - res = PyObject_CallMethodOneArg(self->raw, _PyIO_str_truncate, pos); + res = _PyObject_CallMethodOneArg(self->raw, _PyIO_str_truncate, pos); if (res == NULL) goto end; /* Reset cached position */ @@ -1350,7 +1350,7 @@ buffered_iternext(buffered *self) line = _buffered_readline(self, -1); } else { - line = PyObject_CallMethodNoArgs((PyObject *)self, + line = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_readline); if (line && !PyBytes_Check(line)) { PyErr_Format(PyExc_OSError, @@ -1469,7 +1469,7 @@ _bufferedreader_raw_read(buffered *self, char *start, Py_ssize_t len) raised (see issue #10956). */ do { - res = PyObject_CallMethodOneArg(self->raw, _PyIO_str_readinto, memobj); + res = _PyObject_CallMethodOneArg(self->raw, _PyIO_str_readinto, memobj); } while (res == NULL && _PyIO_trap_eintr()); Py_DECREF(memobj); if (res == NULL) @@ -1568,7 +1568,7 @@ _bufferedreader_read_all(buffered *self) } /* Read until EOF or until read() would block. */ - data = PyObject_CallMethodNoArgs(self->raw, _PyIO_str_read); + data = _PyObject_CallMethodNoArgs(self->raw, _PyIO_str_read); if (data == NULL) goto cleanup; if (data != Py_None && !PyBytes_Check(data)) { @@ -1817,7 +1817,7 @@ _bufferedwriter_raw_write(buffered *self, char *start, Py_ssize_t len) */ do { errno = 0; - res = PyObject_CallMethodOneArg(self->raw, _PyIO_str_write, memobj); + res = _PyObject_CallMethodOneArg(self->raw, _PyIO_str_write, memobj); errnum = errno; } while (res == NULL && _PyIO_trap_eintr()); Py_DECREF(memobj); diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c index 1ff35648e550f3..d51fc944e1a629 100644 --- a/Modules/_io/iobase.c +++ b/Modules/_io/iobase.c @@ -235,7 +235,7 @@ _io__IOBase_close_impl(PyObject *self) Py_RETURN_NONE; } - res = PyObject_CallMethodNoArgs(self, _PyIO_str_flush); + res = _PyObject_CallMethodNoArgs(self, _PyIO_str_flush); PyErr_Fetch(&exc, &val, &tb); rc = _PyObject_SetAttrId(self, &PyId___IOBase_closed, Py_True); @@ -281,7 +281,7 @@ iobase_finalize(PyObject *self) finalization process. */ if (_PyObject_SetAttrId(self, &PyId__finalizing, Py_True)) PyErr_Clear(); - res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_close); + res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_close); /* Silencing I/O errors is bad, but printing spurious tracebacks is equally as bad, and potentially more frequent (because of shutdown issues). */ @@ -382,7 +382,7 @@ _io__IOBase_seekable_impl(PyObject *self) PyObject * _PyIOBase_check_seekable(PyObject *self, PyObject *args) { - PyObject *res = PyObject_CallMethodNoArgs(self, _PyIO_str_seekable); + PyObject *res = _PyObject_CallMethodNoArgs(self, _PyIO_str_seekable); if (res == NULL) return NULL; if (res != Py_True) { @@ -415,7 +415,7 @@ _io__IOBase_readable_impl(PyObject *self) PyObject * _PyIOBase_check_readable(PyObject *self, PyObject *args) { - PyObject *res = PyObject_CallMethodNoArgs(self, _PyIO_str_readable); + PyObject *res = _PyObject_CallMethodNoArgs(self, _PyIO_str_readable); if (res == NULL) return NULL; if (res != Py_True) { @@ -448,7 +448,7 @@ _io__IOBase_writable_impl(PyObject *self) PyObject * _PyIOBase_check_writable(PyObject *self, PyObject *args) { - PyObject *res = PyObject_CallMethodNoArgs(self, _PyIO_str_writable); + PyObject *res = _PyObject_CallMethodNoArgs(self, _PyIO_str_writable); if (res == NULL) return NULL; if (res != Py_True) { @@ -477,7 +477,7 @@ iobase_enter(PyObject *self, PyObject *args) static PyObject * iobase_exit(PyObject *self, PyObject *args) { - return PyObject_CallMethodNoArgs(self, _PyIO_str_close); + return _PyObject_CallMethodNoArgs(self, _PyIO_str_close); } /* Lower-level APIs */ @@ -556,7 +556,7 @@ _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit) PyObject *b; if (peek != NULL) { - PyObject *readahead = PyObject_CallOneArg(peek, _PyLong_One); + PyObject *readahead = _PyObject_CallOneArg(peek, _PyLong_One); if (readahead == NULL) { /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() when EINTR occurs so we needn't do it ourselves. */ @@ -655,7 +655,7 @@ iobase_iter(PyObject *self) static PyObject * iobase_iternext(PyObject *self) { - PyObject *line = PyObject_CallMethodNoArgs(self, _PyIO_str_readline); + PyObject *line = _PyObject_CallMethodNoArgs(self, _PyIO_str_readline); if (line == NULL) return NULL; diff --git a/Modules/_io/stringio.c b/Modules/_io/stringio.c index 28d54e00d8a7be..89b29bb8fbb72b 100644 --- a/Modules/_io/stringio.c +++ b/Modules/_io/stringio.c @@ -408,7 +408,7 @@ stringio_iternext(stringio *self) } else { /* XXX is subclassing StringIO really supported? */ - line = PyObject_CallMethodNoArgs((PyObject *)self, + line = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_readline); if (line && !PyUnicode_Check(line)) { PyErr_Format(PyExc_OSError, diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index b9688a97189404..5ebeb024e57939 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -527,7 +527,7 @@ _io_IncrementalNewlineDecoder_getstate_impl(nldecoder_object *self) unsigned long long flag; if (self->decoder != Py_None) { - PyObject *state = PyObject_CallMethodNoArgs(self->decoder, + PyObject *state = _PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_getstate); if (state == NULL) return NULL; @@ -601,7 +601,7 @@ _io_IncrementalNewlineDecoder_reset_impl(nldecoder_object *self) self->seennl = 0; self->pendingcr = 0; if (self->decoder != Py_None) - return PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_reset); + return _PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_reset); else Py_RETURN_NONE; } @@ -963,7 +963,7 @@ _textiowrapper_fix_encoder_state(textio *self) self->encoding_start_of_stream = 1; - PyObject *cookieObj = PyObject_CallMethodNoArgs( + PyObject *cookieObj = _PyObject_CallMethodNoArgs( self->buffer, _PyIO_str_tell); if (cookieObj == NULL) { return -1; @@ -977,7 +977,7 @@ _textiowrapper_fix_encoder_state(textio *self) if (cmp == 0) { self->encoding_start_of_stream = 0; - PyObject *res = PyObject_CallMethodOneArg( + PyObject *res = _PyObject_CallMethodOneArg( self->encoder, _PyIO_str_setstate, _PyLong_Zero); if (res == NULL) { return -1; @@ -1386,7 +1386,7 @@ _io_TextIOWrapper_reconfigure_impl(textio *self, PyObject *encoding, return NULL; } - PyObject *res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); + PyObject *res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); if (res == NULL) { return NULL; } @@ -1525,7 +1525,7 @@ _io_TextIOWrapper_detach_impl(textio *self) { PyObject *buffer, *res; CHECK_ATTACHED(self); - res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); + res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); if (res == NULL) return NULL; Py_DECREF(res); @@ -1597,7 +1597,7 @@ _textiowrapper_writeflush(textio *self) PyObject *ret; do { - ret = PyObject_CallMethodOneArg(self->buffer, _PyIO_str_write, b); + ret = _PyObject_CallMethodOneArg(self->buffer, _PyIO_str_write, b); } while (ret == NULL && _PyIO_trap_eintr()); Py_DECREF(b); if (ret == NULL) @@ -1667,7 +1667,7 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text) self->encoding_start_of_stream = 0; } else - b = PyObject_CallMethodOneArg(self->encoder, _PyIO_str_encode, text); + b = _PyObject_CallMethodOneArg(self->encoder, _PyIO_str_encode, text); Py_DECREF(text); if (b == NULL) @@ -1718,7 +1718,7 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text) } if (needflush) { - ret = PyObject_CallMethodNoArgs(self->buffer, _PyIO_str_flush); + ret = _PyObject_CallMethodNoArgs(self->buffer, _PyIO_str_flush); if (ret == NULL) return NULL; Py_DECREF(ret); @@ -1808,7 +1808,7 @@ textiowrapper_read_chunk(textio *self, Py_ssize_t size_hint) /* To prepare for tell(), we need to snapshot a point in the file * where the decoder's input buffer is empty. */ - PyObject *state = PyObject_CallMethodNoArgs(self->decoder, + PyObject *state = _PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_getstate); if (state == NULL) return -1; @@ -1849,7 +1849,7 @@ textiowrapper_read_chunk(textio *self, Py_ssize_t size_hint) if (chunk_size == NULL) goto fail; - input_chunk = PyObject_CallMethodOneArg(self->buffer, + input_chunk = _PyObject_CallMethodOneArg(self->buffer, (self->has_read1 ? _PyIO_str_read1: _PyIO_str_read), chunk_size); Py_DECREF(chunk_size); @@ -2393,7 +2393,7 @@ _textiowrapper_decoder_setstate(textio *self, cookie_type *cookie) utf-16, that we are expecting a BOM). */ if (cookie->start_pos == 0 && cookie->dec_flags == 0) - res = PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_reset); + res = _PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_reset); else res = _PyObject_CallMethodId(self->decoder, &PyId_setstate, "((yi))", "", cookie->dec_flags); @@ -2408,11 +2408,11 @@ _textiowrapper_encoder_reset(textio *self, int start_of_stream) { PyObject *res; if (start_of_stream) { - res = PyObject_CallMethodNoArgs(self->encoder, _PyIO_str_reset); + res = _PyObject_CallMethodNoArgs(self->encoder, _PyIO_str_reset); self->encoding_start_of_stream = 1; } else { - res = PyObject_CallMethodOneArg(self->encoder, _PyIO_str_setstate, + res = _PyObject_CallMethodOneArg(self->encoder, _PyIO_str_setstate, _PyLong_Zero); self->encoding_start_of_stream = 0; } @@ -2537,7 +2537,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence) goto fail; } - res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); + res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); if (res == NULL) goto fail; Py_DECREF(res); @@ -2552,7 +2552,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence) posobj = PyLong_FromOff_t(cookie.start_pos); if (posobj == NULL) goto fail; - res = PyObject_CallMethodOneArg(self->buffer, _PyIO_str_seek, posobj); + res = _PyObject_CallMethodOneArg(self->buffer, _PyIO_str_seek, posobj); Py_DECREF(posobj); if (res == NULL) goto fail; @@ -2700,14 +2700,14 @@ _io_TextIOWrapper_tell_impl(textio *self) chars_to_skip = self->decoded_chars_used; /* Decoder state will be restored at the end */ - saved_state = PyObject_CallMethodNoArgs(self->decoder, + saved_state = _PyObject_CallMethodNoArgs(self->decoder, _PyIO_str_getstate); if (saved_state == NULL) goto fail; #define DECODER_GETSTATE() do { \ PyObject *dec_buffer; \ - PyObject *_state = PyObject_CallMethodNoArgs(self->decoder, \ + PyObject *_state = _PyObject_CallMethodNoArgs(self->decoder, \ _PyIO_str_getstate); \ if (_state == NULL) \ goto fail; \ @@ -2870,12 +2870,12 @@ _io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos) CHECK_ATTACHED(self) - res = PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); + res = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_flush); if (res == NULL) return NULL; Py_DECREF(res); - return PyObject_CallMethodOneArg(self->buffer, _PyIO_str_truncate, pos); + return _PyObject_CallMethodOneArg(self->buffer, _PyIO_str_truncate, pos); } static PyObject * @@ -3084,7 +3084,7 @@ textiowrapper_iternext(textio *self) line = _textiowrapper_readline(self, -1); } else { - line = PyObject_CallMethodNoArgs((PyObject *)self, + line = _PyObject_CallMethodNoArgs((PyObject *)self, _PyIO_str_readline); if (line && !PyUnicode_Check(line)) { PyErr_Format(PyExc_OSError, diff --git a/Modules/_json.c b/Modules/_json.c index 2ef955f587c4ac..439414fd59e621 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -777,14 +777,14 @@ _parse_object_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ss *next_idx_ptr = idx + 1; if (has_pairs_hook) { - val = PyObject_CallOneArg(s->object_pairs_hook, rval); + val = _PyObject_CallOneArg(s->object_pairs_hook, rval); Py_DECREF(rval); return val; } /* if object_hook is not None: rval = object_hook(rval) */ if (s->object_hook != Py_None) { - val = PyObject_CallOneArg(s->object_hook, rval); + val = _PyObject_CallOneArg(s->object_hook, rval); Py_DECREF(rval); return val; } @@ -890,7 +890,7 @@ _parse_constant(PyScannerObject *s, const char *constant, Py_ssize_t idx, Py_ssi return NULL; /* rval = parse_constant(constant) */ - rval = PyObject_CallOneArg(s->parse_constant, cstr); + rval = _PyObject_CallOneArg(s->parse_constant, cstr); idx += PyUnicode_GET_LENGTH(cstr); Py_DECREF(cstr); *next_idx_ptr = idx; @@ -989,7 +989,7 @@ _match_number_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t start, Py_ idx - start); if (numstr == NULL) return NULL; - rval = PyObject_CallOneArg(custom_func, numstr); + rval = _PyObject_CallOneArg(custom_func, numstr); } else { Py_ssize_t i, n; @@ -1399,7 +1399,7 @@ encoder_encode_string(PyEncoderObject *s, PyObject *obj) if (s->fast_encode) { return s->fast_encode(NULL, obj); } - encoded = PyObject_CallOneArg(s->encoder, obj); + encoded = _PyObject_CallOneArg(s->encoder, obj); if (encoded != NULL && !PyUnicode_Check(encoded)) { PyErr_Format(PyExc_TypeError, "encoder() must return a string, not %.80s", @@ -1485,7 +1485,7 @@ encoder_listencode_obj(PyEncoderObject *s, _PyAccu *acc, return -1; } } - newobj = PyObject_CallOneArg(s->defaultfn, obj); + newobj = _PyObject_CallOneArg(s->defaultfn, obj); if (newobj == NULL) { Py_XDECREF(ident); return -1; diff --git a/Modules/_operator.c b/Modules/_operator.c index 6d5ec1753a74a7..5aa229fa781ebb 100644 --- a/Modules/_operator.c +++ b/Modules/_operator.c @@ -1682,7 +1682,7 @@ methodcaller_reduce(methodcallerobject *mc, PyObject *Py_UNUSED(ignored)) newargs[0] = (PyObject *)Py_TYPE(mc); newargs[1] = mc->name; - constructor = PyObject_FastCallDict(partial, newargs, 2, mc->kwds); + constructor = _PyObject_FastCallDict(partial, newargs, 2, mc->kwds); Py_DECREF(partial); return Py_BuildValue("NO", constructor, mc->args); diff --git a/Modules/_pickle.c b/Modules/_pickle.c index ec99536933c6af..baa0a274196938 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -359,7 +359,7 @@ _Pickle_FastCall(PyObject *func, PyObject *obj) { PyObject *result; - result = PyObject_CallOneArg(func, obj); + result = _PyObject_CallOneArg(func, obj); Py_DECREF(obj); return result; } @@ -420,7 +420,7 @@ call_method(PyObject *func, PyObject *self, PyObject *obj) return PyObject_CallFunctionObjArgs(func, self, obj, NULL); } else { - return PyObject_CallOneArg(func, obj); + return _PyObject_CallOneArg(func, obj); } } @@ -2296,7 +2296,7 @@ _Pickler_write_bytes(PicklerObject *self, return -1; } } - result = PyObject_CallOneArg(self->write, payload); + result = _PyObject_CallOneArg(self->write, payload); Py_XDECREF(mem); if (result == NULL) { return -1; @@ -2504,7 +2504,7 @@ save_picklebuffer(PicklerObject *self, PyObject *obj) } int in_band = 1; if (self->buffer_callback != NULL) { - PyObject *ret = PyObject_CallOneArg(self->buffer_callback, obj); + PyObject *ret = _PyObject_CallOneArg(self->buffer_callback, obj); if (ret == NULL) { return -1; } @@ -4321,7 +4321,7 @@ save(PicklerObject *self, PyObject *obj, int pers_save) * regular reduction mechanism. */ if (self->reducer_override != NULL) { - reduce_value = PyObject_CallOneArg(self->reducer_override, obj); + reduce_value = _PyObject_CallOneArg(self->reducer_override, obj); if (reduce_value == NULL) { goto error; } diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index 2aed79e14c4b51..80bb44dce9092d 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -80,7 +80,7 @@ _enable_gc(int need_to_reenable_gc, PyObject *gc_module) if (need_to_reenable_gc) { PyErr_Fetch(&exctype, &val, &tb); - result = PyObject_CallMethodNoArgs( + result = _PyObject_CallMethodNoArgs( gc_module, _posixsubprocessstate_global->enable); if (exctype != NULL) { PyErr_Restore(exctype, val, tb); @@ -657,7 +657,7 @@ subprocess_fork_exec(PyObject* self, PyObject *args) gc_module = PyImport_ImportModule("gc"); if (gc_module == NULL) return NULL; - result = PyObject_CallMethodNoArgs( + result = _PyObject_CallMethodNoArgs( gc_module, _posixsubprocessstate_global->isenabled); if (result == NULL) { Py_DECREF(gc_module); @@ -669,7 +669,7 @@ subprocess_fork_exec(PyObject* self, PyObject *args) Py_DECREF(gc_module); return NULL; } - result = PyObject_CallMethodNoArgs( + result = _PyObject_CallMethodNoArgs( gc_module, _posixsubprocessstate_global->disable); if (result == NULL) { Py_DECREF(gc_module); diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c index f0fdb0382c5d35..1f4bf74fc7a1e2 100644 --- a/Modules/_randommodule.c +++ b/Modules/_randommodule.c @@ -287,7 +287,7 @@ random_seed(RandomObject *self, PyObject *arg) /* Calling int.__abs__() prevents calling arg.__abs__(), which might return an invalid value. See issue #31478. */ args[0] = arg; - n = PyObject_Vectorcall(_randomstate_global->Long___abs__, args, 0, + n = _PyObject_Vectorcall(_randomstate_global->Long___abs__, args, 0, NULL); } else { diff --git a/Modules/_sqlite/cache.c b/Modules/_sqlite/cache.c index 758fc022f78108..7552d1b145394b 100644 --- a/Modules/_sqlite/cache.c +++ b/Modules/_sqlite/cache.c @@ -183,7 +183,7 @@ PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* key) } } - /* We cannot replace this by PyObject_CallOneArg() since + /* We cannot replace this by _PyObject_CallOneArg() since * PyObject_CallFunction() has a special case when using a * single tuple as argument. */ data = PyObject_CallFunction(self->factory, "O", key); diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 697295da9ce397..64051669185ba6 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -308,7 +308,7 @@ PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, factory = (PyObject*)&pysqlite_CursorType; } - cursor = PyObject_CallOneArg(factory, (PyObject *)self); + cursor = _PyObject_CallOneArg(factory, (PyObject *)self); if (cursor == NULL) return NULL; if (!PyObject_TypeCheck(cursor, &pysqlite_CursorType)) { @@ -975,7 +975,7 @@ static void _trace_callback(void* user_arg, const char* statement_string) py_statement = PyUnicode_DecodeUTF8(statement_string, strlen(statement_string), "replace"); if (py_statement) { - ret = PyObject_CallOneArg((PyObject*)user_arg, py_statement); + ret = _PyObject_CallOneArg((PyObject*)user_arg, py_statement); Py_DECREF(py_statement); } @@ -1472,7 +1472,7 @@ pysqlite_connection_iterdump(pysqlite_Connection* self, PyObject* args) goto finally; } - retval = PyObject_CallOneArg(pyfn_iterdump, (PyObject *)self); + retval = _PyObject_CallOneArg(pyfn_iterdump, (PyObject *)self); finally: Py_XDECREF(module); diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 2ceeab775c8904..45f5865590d692 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -266,7 +266,7 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self) item = PyBytes_FromStringAndSize(val_str, nbytes); if (!item) goto error; - converted = PyObject_CallOneArg(converter, item); + converted = _PyObject_CallOneArg(converter, item); Py_DECREF(item); } } else { diff --git a/Modules/_sqlite/microprotocols.c b/Modules/_sqlite/microprotocols.c index 3414be3894e6d2..59a5e228454ec4 100644 --- a/Modules/_sqlite/microprotocols.c +++ b/Modules/_sqlite/microprotocols.c @@ -92,7 +92,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) Py_DECREF(key); if (adapter) { Py_INCREF(adapter); - adapted = PyObject_CallOneArg(adapter, obj); + adapted = _PyObject_CallOneArg(adapter, obj); Py_DECREF(adapter); return adapted; } @@ -105,7 +105,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) return NULL; } if (adapter) { - adapted = PyObject_CallOneArg(adapter, obj); + adapted = _PyObject_CallOneArg(adapter, obj); Py_DECREF(adapter); if (adapted == Py_None) { @@ -124,7 +124,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) return NULL; } if (adapter) { - adapted = PyObject_CallOneArg(adapter, proto); + adapted = _PyObject_CallOneArg(adapter, proto); Py_DECREF(adapter); if (adapted == Py_None) { diff --git a/Modules/_sre.c b/Modules/_sre.c index 112eea07540977..f4f9d01dfccfdd 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -1082,7 +1082,7 @@ pattern_subx(PatternObject* self, PyObject* ptemplate, PyObject* string, match = pattern_new_match(self, &state, 1); if (!match) goto error; - item = PyObject_CallOneArg(filter, match); + item = _PyObject_CallOneArg(filter, match); Py_DECREF(match); if (!item) goto error; diff --git a/Modules/_struct.c b/Modules/_struct.c index 0cdfe268e645fb..cc536b46a623ec 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -2097,7 +2097,7 @@ cache_struct_converter(PyObject *fmt, PyStructObject **ptr) return 0; } - s_object = PyObject_CallOneArg(_structmodulestate_global->PyStructType, fmt); + s_object = _PyObject_CallOneArg(_structmodulestate_global->PyStructType, fmt); if (s_object != NULL) { if (PyDict_GET_SIZE(cache) >= MAXCACHE) PyDict_Clear(cache); diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 16c62eeb8e7684..943bee6e21e197 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -4851,7 +4851,7 @@ test_pyobject_fastcalldict(PyObject *self, PyObject *args) return NULL; } - return PyObject_FastCallDict(func, stack, nargs, kwargs); + return _PyObject_FastCallDict(func, stack, nargs, kwargs); } @@ -4885,7 +4885,7 @@ test_pyobject_vectorcall(PyObject *self, PyObject *args) PyErr_SetString(PyExc_TypeError, "kwnames must be None or a tuple"); return NULL; } - return PyObject_Vectorcall(func, stack, nargs, kwnames); + return _PyObject_Vectorcall(func, stack, nargs, kwnames); } @@ -5258,7 +5258,7 @@ meth_fastcall_keywords(PyObject* self, PyObject* const* args, if (pyargs == NULL) { return NULL; } - PyObject *pykwargs = PyObject_Vectorcall((PyObject*)&PyDict_Type, + PyObject *pykwargs = _PyObject_Vectorcall((PyObject*)&PyDict_Type, args + nargs, 0, kwargs); return Py_BuildValue("NNN", _null_to_none(self), pyargs, pykwargs); } @@ -6138,7 +6138,7 @@ static PyTypeObject MethodDescriptorBase_Type = { .tp_call = PyVectorcall_Call, .tp_vectorcall_offset = offsetof(MethodDescriptorObject, vectorcall), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_METHOD_DESCRIPTOR | Py_TPFLAGS_HAVE_VECTORCALL, + Py_TPFLAGS_METHOD_DESCRIPTOR | _Py_TPFLAGS_HAVE_VECTORCALL, .tp_descr_get = func_descr_get, }; @@ -6177,7 +6177,7 @@ static PyTypeObject MethodDescriptor2_Type = { .tp_new = MethodDescriptor2_new, .tp_call = PyVectorcall_Call, .tp_vectorcall_offset = offsetof(MethodDescriptor2Object, vectorcall), - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_VECTORCALL, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | _Py_TPFLAGS_HAVE_VECTORCALL, }; PyDoc_STRVAR(heapgctype__doc__, diff --git a/Modules/_xxtestfuzz/fuzzer.c b/Modules/_xxtestfuzz/fuzzer.c index 74ba819b8b50be..dae1eaeabd000b 100644 --- a/Modules/_xxtestfuzz/fuzzer.c +++ b/Modules/_xxtestfuzz/fuzzer.c @@ -104,7 +104,7 @@ static int fuzz_json_loads(const char* data, size_t size) { if (input_bytes == NULL) { return 0; } - PyObject* parsed = PyObject_CallOneArg(json_loads_method, input_bytes); + PyObject* parsed = _PyObject_CallOneArg(json_loads_method, input_bytes); if (parsed == NULL) { /* Ignore ValueError as the fuzzer will more than likely generate some invalid json and values */ @@ -263,7 +263,7 @@ static int fuzz_sre_match(const char* data, size_t size) { PyObject* pattern = compiled_patterns[idx]; PyObject* match_callable = PyObject_GetAttrString(pattern, "match"); - PyObject* matches = PyObject_CallOneArg(match_callable, to_match); + PyObject* matches = _PyObject_CallOneArg(match_callable, to_match); Py_XDECREF(matches); Py_DECREF(match_callable); diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h index 8f6f880cadf71e..7ed836598b36d8 100644 --- a/Modules/cjkcodecs/cjkcodecs.h +++ b/Modules/cjkcodecs/cjkcodecs.h @@ -291,7 +291,7 @@ getcodec(PyObject *self, PyObject *encoding) if (codecobj == NULL) return NULL; - r = PyObject_CallOneArg(cofunc, codecobj); + r = _PyObject_CallOneArg(cofunc, codecobj); Py_DECREF(codecobj); return r; diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index c798fd6dade11b..f24ec933508f14 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -92,7 +92,7 @@ call_error_callback(PyObject *errors, PyObject *exc) if (cb == NULL) return NULL; - r = PyObject_CallOneArg(cb, exc); + r = _PyObject_CallOneArg(cb, exc); Py_DECREF(cb); return r; } diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index ed121b4ea6753e..b11ae842e2295a 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -875,7 +875,7 @@ handle_weakrefs(PyGC_Head *unreachable, PyGC_Head *old) _PyObject_ASSERT(op, callback != NULL); /* copy-paste of weakrefobject.c's handle_callback() */ - temp = PyObject_CallOneArg(callback, (PyObject *)wr); + temp = _PyObject_CallOneArg(callback, (PyObject *)wr); if (temp == NULL) PyErr_WriteUnraisable(callback); else diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 6b32b555c32323..0cb472966d1f95 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -134,7 +134,7 @@ groupby_step(groupbyobject *gbo) newkey = newvalue; Py_INCREF(newvalue); } else { - newkey = PyObject_CallOneArg(gbo->keyfunc, newvalue); + newkey = _PyObject_CallOneArg(gbo->keyfunc, newvalue); if (newkey == NULL) { Py_DECREF(newvalue); return -1; @@ -1219,7 +1219,7 @@ dropwhile_next(dropwhileobject *lz) if (lz->start == 1) return item; - good = PyObject_CallOneArg(lz->func, item); + good = _PyObject_CallOneArg(lz->func, item); if (good == NULL) { Py_DECREF(item); return NULL; @@ -1382,7 +1382,7 @@ takewhile_next(takewhileobject *lz) if (item == NULL) return NULL; - good = PyObject_CallOneArg(lz->func, item); + good = _PyObject_CallOneArg(lz->func, item); if (good == NULL) { Py_DECREF(item); return NULL; @@ -3918,7 +3918,7 @@ filterfalse_next(filterfalseobject *lz) ok = PyObject_IsTrue(item); } else { PyObject *good; - good = PyObject_CallOneArg(lz->func, item); + good = _PyObject_CallOneArg(lz->func, item); if (good == NULL) { Py_DECREF(item); return NULL; diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index a7f8b5086bbfac..90167342fee50a 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -119,7 +119,7 @@ set_error(xmlparseobject *self, enum XML_Error code) XML_ErrorString(code), lineno, column); if (buffer == NULL) return NULL; - err = PyObject_CallOneArg(ErrorObject, buffer); + err = _PyObject_CallOneArg(ErrorObject, buffer); Py_DECREF(buffer); if ( err != NULL && set_error_attr(err, "code", code) diff --git a/Objects/abstract.c b/Objects/abstract.c index c285a6dfd63f10..dc8ba10762de6d 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)) { @@ -2499,7 +2499,7 @@ object_isinstance(PyThreadState *tstate, PyObject *inst, PyObject *cls) Py_DECREF(checker); return ok; } - PyObject *res = PyObject_CallOneArg(checker, inst); + PyObject *res = _PyObject_CallOneArg(checker, inst); _Py_LeaveRecursiveCall(tstate); Py_DECREF(checker); if (res != NULL) { @@ -2582,7 +2582,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 300f6a32cd15af..c9bf11bba1dd23 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 1eaafcd08cb58a..f9823f18e8699e 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2274,7 +2274,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 259dce7e22d8bd..0f8cb5aa246b08 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_FastCallDict() 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_FastCallDict(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 36bccb86485185..db53f04862cd6b 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 fa7f5b9910d146..342b993e090390 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -452,7 +452,7 @@ classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args, if (bound == NULL) { return NULL; } - PyObject *res = PyObject_FastCallDict(bound, _PyTuple_ITEMS(args)+1, + PyObject *res = _PyObject_FastCallDict(bound, _PyTuple_ITEMS(args)+1, argc-1, kwds); Py_DECREF(bound); return res; @@ -672,7 +672,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 5dccbd135e2ae8..87f88abbe53bd9 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -2117,7 +2117,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 52b21154a96d90..3ec5a00f30f6a8 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -136,7 +136,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 dfaead4f0667db..4fc412b43f7a3e 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -1511,7 +1511,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 e42caee1e74570..b6ffc2a184c99b 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 c837cb08ca3c81..c5fe9999af26e2 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 1510ca052ff91c..bc8425cae63e12 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2257,7 +2257,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 461f2723949fed..be9301f85162c8 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -5578,7 +5578,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 e24d94e93c9a74..66920eaf947abd 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -1962,7 +1962,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; @@ -2001,7 +2001,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 29ce319de7036f..6a37238d86d8d4 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 f281d898f484ea..03c7381311aa14 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -736,7 +736,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); } _Py_IDENTIFIER(__name__); mod_name = _PyDict_GetItemId(m->md_dict, &PyId___name__); diff --git a/Objects/typeobject.c b/Objects/typeobject.c index b22130b4771f80..720363410ceb1e 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1463,7 +1463,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); @@ -3664,7 +3664,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 */ @@ -5194,17 +5194,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); } @@ -5280,14 +5280,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); } @@ -6607,7 +6607,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; } @@ -7566,7 +7566,7 @@ init_subclass(PyTypeObject *type, PyObject *kwds) } - result = PyObject_FastCallDict(func, NULL, 0, kwds); + result = _PyObject_FastCallDict(func, NULL, 0, kwds); Py_DECREF(func); if (result == NULL) { return -1; diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 6a6f1241631b0f..1ec2accdb09f20 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -4255,7 +4255,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)) { @@ -4359,7 +4359,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)) { @@ -6806,7 +6806,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)) { @@ -8788,7 +8788,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 cd8412fd3dc05a..bf79e0c7ecbcc9 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -931,7 +931,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); diff --git a/Python/_warnings.c b/Python/_warnings.c index e588d060582f1d..b8585d204787db 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -592,7 +592,7 @@ call_show_warning(PyObject *category, PyObject *text, PyObject *message, if (msg == NULL) goto error; - res = PyObject_CallOneArg(show_fn, msg); + res = _PyObject_CallOneArg(show_fn, msg); Py_DECREF(show_fn); Py_DECREF(msg); @@ -653,7 +653,7 @@ warn_explicit(PyObject *category, PyObject *message, } else { text = message; - message = PyObject_CallOneArg(category, message); + message = _PyObject_CallOneArg(category, message); if (message == NULL) goto cleanup; } @@ -998,7 +998,7 @@ get_source_line(PyObject *module_globals, int lineno) return NULL; } /* Call get_source() to get the source code. */ - source = PyObject_CallOneArg(get_source, module_name); + source = _PyObject_CallOneArg(get_source, module_name); Py_DECREF(get_source); Py_DECREF(module_name); if (!source) { @@ -1285,7 +1285,7 @@ _PyErr_WarnUnawaitedCoroutine(PyObject *coro) int warned = 0; PyObject *fn = get_warnings_attr(&PyId__warn_unawaited_coroutine, 1); if (fn) { - PyObject *res = PyObject_CallOneArg(fn, coro); + PyObject *res = _PyObject_CallOneArg(fn, coro); Py_DECREF(fn); if (res || PyErr_ExceptionMatches(PyExc_RuntimeWarning)) { warned = 1; diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 8dbde32d91b46c..34267685be2f1f 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -55,7 +55,7 @@ update_bases(PyObject *bases, PyObject *const *args, Py_ssize_t nargs) } continue; } - new_base = PyObject_CallOneArg(meth, bases); + new_base = _PyObject_CallOneArg(meth, bases); Py_DECREF(meth); if (!new_base) { goto error; @@ -202,7 +202,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs, } else { PyObject *pargs[2] = {name, bases}; - ns = PyObject_FastCallDict(prep, pargs, 2, mkw); + ns = _PyObject_FastCallDict(prep, pargs, 2, mkw); Py_DECREF(prep); } if (ns == NULL) { @@ -228,7 +228,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs, } } PyObject *margs[3] = {name, bases, ns}; - cls = PyObject_FastCallDict(meta, margs, 3, mkw); + cls = _PyObject_FastCallDict(meta, margs, 3, mkw); if (cls != NULL && PyType_Check(cls) && PyCell_Check(cell)) { PyObject *cell_cls = PyCell_GET(cell); if (cell_cls != cls) { @@ -488,7 +488,7 @@ builtin_breakpoint(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb } Py_INCREF(hook); - PyObject *retval = PyObject_Vectorcall(hook, args, nargs, keywords); + PyObject *retval = _PyObject_Vectorcall(hook, args, nargs, keywords); Py_DECREF(hook); return retval; } @@ -574,7 +574,7 @@ filter_next(filterobject *lz) ok = PyObject_IsTrue(item); } else { PyObject *good; - good = PyObject_CallOneArg(lz->func, item); + good = _PyObject_CallOneArg(lz->func, item); if (good == NULL) { Py_DECREF(item); return NULL; @@ -1625,7 +1625,7 @@ min_max(PyObject *args, PyObject *kwds, int op) while (( item = PyIter_Next(it) )) { /* get the value from the key function */ if (keyfunc != NULL) { - val = PyObject_CallOneArg(keyfunc, item); + val = _PyObject_CallOneArg(keyfunc, item); if (val == NULL) goto Fail_it_item; } @@ -2172,7 +2172,7 @@ builtin_round_impl(PyObject *module, PyObject *number, PyObject *ndigits) if (ndigits == Py_None) result = _PyObject_CallNoArg(round); else - result = PyObject_CallOneArg(round, ndigits); + result = _PyObject_CallOneArg(round, ndigits); Py_DECREF(round); return result; } @@ -2228,7 +2228,7 @@ builtin_sorted(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject } assert(nargs >= 1); - v = PyObject_Vectorcall(callable, args + 1, nargs - 1, kwnames); + v = _PyObject_Vectorcall(callable, args + 1, nargs - 1, kwnames); Py_DECREF(callable); if (v == NULL) { Py_DECREF(newlist); diff --git a/Python/ceval.c b/Python/ceval.c index 17b00e4529d18c..bd9454b2812ddf 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1880,7 +1880,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) Py_DECREF(value); goto error; } - res = PyObject_CallOneArg(hook, value); + res = _PyObject_CallOneArg(hook, value); Py_DECREF(value); if (res == NULL) goto error; @@ -3235,7 +3235,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) assert(!PyLong_Check(exc)); exit_func = PEEK(7); PyObject *stack[4] = {NULL, exc, val, tb}; - res = PyObject_Vectorcall(exit_func, stack + 1, + res = _PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; @@ -4808,7 +4808,7 @@ trace_call_function(PyThreadState *tstate, { PyObject *x; if (PyCFunction_Check(func)) { - C_TRACE(x, PyObject_Vectorcall(func, args, nargs, kwnames)); + C_TRACE(x, _PyObject_Vectorcall(func, args, nargs, kwnames)); return x; } else if (Py_TYPE(func) == &PyMethodDescr_Type && nargs > 0) { @@ -4824,13 +4824,13 @@ trace_call_function(PyThreadState *tstate, if (func == NULL) { return NULL; } - C_TRACE(x, PyObject_Vectorcall(func, + C_TRACE(x, _PyObject_Vectorcall(func, args+1, nargs-1, kwnames)); Py_DECREF(func); return x; } - return PyObject_Vectorcall(func, args, nargs | PY_VECTORCALL_ARGUMENTS_OFFSET, kwnames); + return _PyObject_Vectorcall(func, args, nargs | PY_VECTORCALL_ARGUMENTS_OFFSET, kwnames); } /* Issue #29227: Inline call_function() into _PyEval_EvalFrameDefault() @@ -4849,7 +4849,7 @@ call_function(PyThreadState *tstate, PyObject ***pp_stack, Py_ssize_t oparg, PyO x = trace_call_function(tstate, func, stack, nargs, kwnames); } else { - x = PyObject_Vectorcall(func, stack, nargs | PY_VECTORCALL_ARGUMENTS_OFFSET, kwnames); + x = _PyObject_Vectorcall(func, stack, nargs | PY_VECTORCALL_ARGUMENTS_OFFSET, kwnames); } assert((x != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); diff --git a/Python/codecs.c b/Python/codecs.c index bfd418e312e573..08e9b916f201d5 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -147,7 +147,7 @@ PyObject *_PyCodec_Lookup(const char *encoding) func = PyList_GetItem(interp->codec_search_path, i); if (func == NULL) goto onError; - result = PyObject_CallOneArg(func, v); + result = _PyObject_CallOneArg(func, v); if (result == NULL) goto onError; if (result == Py_None) { @@ -317,7 +317,7 @@ PyObject *codec_getstreamcodec(const char *encoding, if (errors != NULL) streamcodec = PyObject_CallFunction(codeccls, "Os", stream, errors); else - streamcodec = PyObject_CallOneArg(codeccls, stream); + streamcodec = _PyObject_CallOneArg(codeccls, stream); Py_DECREF(codecs); return streamcodec; } diff --git a/Python/errors.c b/Python/errors.c index c55bb9d53b8c36..d65707e7f97f59 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -93,7 +93,7 @@ _PyErr_CreateException(PyObject *exception, PyObject *value) return PyObject_Call(exception, value, NULL); } else { - return PyObject_CallOneArg(exception, value); + return _PyObject_CallOneArg(exception, value); } } @@ -901,7 +901,7 @@ PyErr_SetImportErrorSubclass(PyObject *exception, PyObject *msg, goto done; } - error = PyObject_FastCallDict(exception, &msg, 1, kwargs); + error = _PyObject_FastCallDict(exception, &msg, 1, kwargs); if (error != NULL) { _PyErr_SetObject(tstate, (PyObject *)Py_TYPE(error), error); Py_DECREF(error); @@ -1418,7 +1418,7 @@ _PyErr_WriteUnraisableMsg(const char *err_msg_str, PyObject *obj) goto default_hook; } - PyObject *res = PyObject_CallOneArg(hook, hook_args); + PyObject *res = _PyObject_CallOneArg(hook, hook_args); Py_DECREF(hook_args); if (res != NULL) { Py_DECREF(res); diff --git a/Python/import.c b/Python/import.c index 92136581945e4a..045b6d0a9bf6f9 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1203,7 +1203,7 @@ get_path_importer(PyThreadState *tstate, PyObject *path_importer_cache, PyObject *hook = PyList_GetItem(path_hooks, j); if (hook == NULL) return NULL; - importer = PyObject_CallOneArg(hook, p); + importer = _PyObject_CallOneArg(hook, p); if (importer != NULL) break; diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 8900ecf2752285..9f866a2a3d2fa0 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -519,7 +519,7 @@ sys_breakpointhook(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb return NULL; } PyMem_RawFree(envar); - PyObject *retval = PyObject_Vectorcall(hook, args, nargs, keywords); + PyObject *retval = _PyObject_Vectorcall(hook, args, nargs, keywords); Py_DECREF(hook); return retval; From 1f7c7460dcb7976ca9424b34ae995d6782508cf4 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Thu, 30 Jan 2020 13:18:31 +0100 Subject: [PATCH 08/10] Rename PyObject_FastCallDict to PyObject_VectorcallDict --- Doc/c-api/call.rst | 14 ++++++++------ Include/cpython/abstract.h | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Doc/c-api/call.rst b/Doc/c-api/call.rst index 44f1b7323ff6d1..06db12666d787c 100644 --- a/Doc/c-api/call.rst +++ b/Doc/c-api/call.rst @@ -109,10 +109,12 @@ function as with any other callable. In CPython 3.8, the vectorcall API and related functions were available provisionally under names with a leading underscore: ``_PyObject_Vectorcall``, ``_Py_TPFLAGS_HAVE_VECTORCALL``, - ``_PyObject_VectorcallMethod``, ``_PyObject_FastCallDict``, - ``_PyVectorcall_Function``, ``_PyObject_CallOneArg``, - ``_PyObject_CallMethodNoArgs``, ``_PyObject_CallMethodOneArg``. - These are still defined as aliases of the non-underscored names. + ``_PyObject_VectorcallMethod``, ``_PyVectorcall_Function``, + ``_PyObject_CallOneArg``, ``_PyObject_CallMethodNoArgs``, + ``_PyObject_CallMethodOneArg``. + Additionally, ``PyObject_VectorcallDict`` was available as + ``_PyObject_FastCallDict``. + The old names are still defined as aliases of the new, non-underscored names. Recursion Control @@ -214,7 +216,7 @@ please see individual documentation for details. +------------------------------------------+------------------+--------------------+---------------+ | :c:func:`PyObject_Vectorcall` | ``PyObject *`` | vectorcall | vectorcall | +------------------------------------------+------------------+--------------------+---------------+ -| :c:func:`PyObject_FastCallDict` | ``PyObject *`` | vectorcall | dict/``NULL`` | +| :c:func:`PyObject_VectorcallDict` | ``PyObject *`` | vectorcall | dict/``NULL`` | +------------------------------------------+------------------+--------------------+---------------+ | :c:func:`PyObject_VectorcallMethod` | arg + name | vectorcall | vectorcall | +------------------------------------------+------------------+--------------------+---------------+ @@ -374,7 +376,7 @@ please see individual documentation for details. .. versionadded:: 3.9 -.. c:function:: PyObject* PyObject_FastCallDict(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwdict) +.. c:function:: PyObject* PyObject_VectorcallDict(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwdict) Call *callable* with positional arguments passed exactly as in the vectorcall_ protocol, but with keyword arguments passed as a dictionary *kwdict*. diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index ba2cf8dad7605e..87749625cee63d 100644 --- a/Include/cpython/abstract.h +++ b/Include/cpython/abstract.h @@ -124,7 +124,7 @@ PyObject_Vectorcall(PyObject *callable, PyObject *const *args, // Backwards compatibility aliases for API that was provisional in Python 3.8 #define _PyObject_Vectorcall PyObject_Vectorcall #define _PyObject_VectorcallMethod PyObject_VectorcallMethod -#define _PyObject_FastCallDict PyObject_FastCallDict +#define _PyObject_FastCallDict PyObject_VectorcallDict #define _PyVectorcall_Function PyVectorcall_Function #define _PyObject_CallOneArg PyObject_CallOneArg #define _PyObject_CallMethodNoArgs PyObject_CallMethodNoArgs @@ -132,7 +132,7 @@ PyObject_Vectorcall(PyObject *callable, PyObject *const *args, /* Same as PyObject_Vectorcall except that keyword arguments are passed as dict, which may be NULL if there are no keyword arguments. */ -PyAPI_FUNC(PyObject *) PyObject_FastCallDict( +PyAPI_FUNC(PyObject *) PyObject_VectorcallDict( PyObject *callable, PyObject *const *args, size_t nargsf, From 3fc5442bc2b03a4301c0caa637a5e3ffb0289417 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Thu, 30 Jan 2020 13:26:04 +0100 Subject: [PATCH 09/10] Expand the NEWS entry --- .../next/C API/2020-01-07-13-46-40.bpo-39245.G7wog6.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/C API/2020-01-07-13-46-40.bpo-39245.G7wog6.rst b/Misc/NEWS.d/next/C API/2020-01-07-13-46-40.bpo-39245.G7wog6.rst index 4578ef87757cd6..e5836b5255d3d8 100644 --- a/Misc/NEWS.d/next/C API/2020-01-07-13-46-40.bpo-39245.G7wog6.rst +++ b/Misc/NEWS.d/next/C API/2020-01-07-13-46-40.bpo-39245.G7wog6.rst @@ -1 +1,5 @@ -The Vectorcall API (PEP 590) was made public. +The Vectorcall API (PEP 590) was made public, adding the functions +``PyObject_Vectorcall``, ``PyObject_VectorcallMethod``, +``PyVectorcall_Function``, ``PyObject_CallOneArg``, +``PyObject_CallMethodNoArgs``, ``PyObject_CallMethodOneArg``, +``PyObject_FastCallDict``, and the flag ``Py_TPFLAGS_HAVE_VECTORCALL``. From 9fff79b7bda5ef788e3982d97a75e9dbf08f38bd Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 4 Feb 2020 17:25:38 +0100 Subject: [PATCH 10/10] Remove underscores from comments --- Include/cpython/abstract.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index 87749625cee63d..4bd7b1a61a5325 100644 --- a/Include/cpython/abstract.h +++ b/Include/cpython/abstract.h @@ -29,7 +29,7 @@ PyAPI_FUNC(PyObject *) _PyStack_AsDict( /* Suggested size (number of positional arguments) for arrays of PyObject* allocated on a C stack to avoid allocating memory on the heap memory. Such array is used to pass positional arguments to call functions of the - _PyObject_Vectorcall() family. + PyObject_Vectorcall() family. The size is chosen to not abuse the C stack and so limit the risk of stack overflow. The size is also chosen to allow using the small stack for most @@ -45,8 +45,8 @@ PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult( /* === Vectorcall protocol (PEP 590) ============================= */ -/* Call callable using tp_call. Arguments are like _PyObject_Vectorcall() - or _PyObject_FastCallDict() (both forms are supported), +/* Call callable using tp_call. Arguments are like PyObject_Vectorcall() + or PyObject_FastCallDict() (both forms are supported), except that nargs is plainly the number of arguments without flags. */ PyAPI_FUNC(PyObject *) _PyObject_MakeTpCall( PyThreadState *tstate,