Kaydet (Commit) cb2128ca authored tarafından Victor Stinner's avatar Victor Stinner

_asyncio uses _PyObject_CallMethodIdObjArgs()

Issue #28920: Replace _PyObject_CallMethodId(obj, meth, "O", arg) with
_PyObject_CallMethodIdObjArgs(obj, meth, arg, NULL) to avoid
_PyObject_CallMethodId() special case when arg is a tuple.

If arg is a tuple, _PyObject_CallMethodId() unpacks the tuple: obj.meth(*arg).
üst 0bf59062
...@@ -1327,7 +1327,7 @@ _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop) ...@@ -1327,7 +1327,7 @@ _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop)
return -1; return -1;
} }
res = _PyObject_CallMethodId(all_tasks, &PyId_add, "O", self, NULL); res = _PyObject_CallMethodIdObjArgs(all_tasks, &PyId_add, self, NULL);
if (res == NULL) { if (res == NULL) {
return -1; return -1;
} }
...@@ -1838,8 +1838,8 @@ task_call_wakeup(TaskObj *task, PyObject *fut) ...@@ -1838,8 +1838,8 @@ task_call_wakeup(TaskObj *task, PyObject *fut)
} }
else { else {
/* `task` is a subclass of Task */ /* `task` is a subclass of Task */
return _PyObject_CallMethodId( return _PyObject_CallMethodIdObjArgs((PyObject*)task, &PyId__wakeup,
(PyObject*)task, &PyId__wakeup, "O", fut, NULL); fut, NULL);
} }
} }
...@@ -1854,8 +1854,8 @@ task_call_step(TaskObj *task, PyObject *arg) ...@@ -1854,8 +1854,8 @@ task_call_step(TaskObj *task, PyObject *arg)
if (arg == NULL) { if (arg == NULL) {
arg = Py_None; arg = Py_None;
} }
return _PyObject_CallMethodId( return _PyObject_CallMethodIdObjArgs((PyObject*)task, &PyId__step,
(PyObject*)task, &PyId__step, "O", arg, NULL); arg, NULL);
} }
} }
...@@ -1869,8 +1869,8 @@ task_call_step_soon(TaskObj *task, PyObject *arg) ...@@ -1869,8 +1869,8 @@ task_call_step_soon(TaskObj *task, PyObject *arg)
return -1; return -1;
} }
handle = _PyObject_CallMethodId( handle = _PyObject_CallMethodIdObjArgs(task->task_loop, &PyId_call_soon,
task->task_loop, &PyId_call_soon, "O", cb, NULL); cb, NULL);
Py_DECREF(cb); Py_DECREF(cb);
if (handle == NULL) { if (handle == NULL) {
return -1; return -1;
...@@ -2135,8 +2135,9 @@ task_step_impl(TaskObj *task, PyObject *exc) ...@@ -2135,8 +2135,9 @@ task_step_impl(TaskObj *task, PyObject *exc)
if (wrapper == NULL) { if (wrapper == NULL) {
goto fail; goto fail;
} }
res = _PyObject_CallMethodId( res = _PyObject_CallMethodIdObjArgs(result,
result, &PyId_add_done_callback, "O", wrapper, NULL); &PyId_add_done_callback,
wrapper, NULL);
Py_DECREF(wrapper); Py_DECREF(wrapper);
if (res == NULL) { if (res == NULL) {
goto fail; goto fail;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment