Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-39245: Switch to public API for Vectorcall #18460

Merged
merged 2 commits into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Include/cpython/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def test_fastcall(self):
self.check_result(result, expected)

def test_vectorcall_dict(self):
# Test _PyObject_FastCallDict()
# Test PyObject_VectorcallDict()

for func, args, expected in self.CALLS_POSARGS:
with self.subTest(func=func, args=args):
Expand All @@ -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):
Expand Down Expand Up @@ -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

Expand Down
22 changes: 11 additions & 11 deletions Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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 *
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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]
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Modules/_collectionsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions Modules/_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_VectorcallDict(type, &dialect_inst, 1, kwargs);
}
else {
return _PyObject_FastCallDict(type, NULL, 0, kwargs);
return PyObject_VectorcallDict(type, NULL, 0, kwargs);
}
}

Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions Modules/_ctypes/callproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1835,15 +1835,15 @@ 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;
}
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;
}
Expand Down
16 changes: 8 additions & 8 deletions Modules/_elementtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions Modules/_functoolsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 */
Expand Down
Loading