Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb2128c

Browse files
committed
_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).
1 parent 0bf5906 commit cb2128c

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

Modules/_asynciomodule.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop)
13271327
return -1;
13281328
}
13291329

1330-
res = _PyObject_CallMethodId(all_tasks, &PyId_add, "O", self, NULL);
1330+
res = _PyObject_CallMethodIdObjArgs(all_tasks, &PyId_add, self, NULL);
13311331
if (res == NULL) {
13321332
return -1;
13331333
}
@@ -1838,8 +1838,8 @@ task_call_wakeup(TaskObj *task, PyObject *fut)
18381838
}
18391839
else {
18401840
/* `task` is a subclass of Task */
1841-
return _PyObject_CallMethodId(
1842-
(PyObject*)task, &PyId__wakeup, "O", fut, NULL);
1841+
return _PyObject_CallMethodIdObjArgs((PyObject*)task, &PyId__wakeup,
1842+
fut, NULL);
18431843
}
18441844
}
18451845

@@ -1854,8 +1854,8 @@ task_call_step(TaskObj *task, PyObject *arg)
18541854
if (arg == NULL) {
18551855
arg = Py_None;
18561856
}
1857-
return _PyObject_CallMethodId(
1858-
(PyObject*)task, &PyId__step, "O", arg, NULL);
1857+
return _PyObject_CallMethodIdObjArgs((PyObject*)task, &PyId__step,
1858+
arg, NULL);
18591859
}
18601860
}
18611861

@@ -1869,8 +1869,8 @@ task_call_step_soon(TaskObj *task, PyObject *arg)
18691869
return -1;
18701870
}
18711871

1872-
handle = _PyObject_CallMethodId(
1873-
task->task_loop, &PyId_call_soon, "O", cb, NULL);
1872+
handle = _PyObject_CallMethodIdObjArgs(task->task_loop, &PyId_call_soon,
1873+
cb, NULL);
18741874
Py_DECREF(cb);
18751875
if (handle == NULL) {
18761876
return -1;
@@ -2135,8 +2135,9 @@ task_step_impl(TaskObj *task, PyObject *exc)
21352135
if (wrapper == NULL) {
21362136
goto fail;
21372137
}
2138-
res = _PyObject_CallMethodId(
2139-
result, &PyId_add_done_callback, "O", wrapper, NULL);
2138+
res = _PyObject_CallMethodIdObjArgs(result,
2139+
&PyId_add_done_callback,
2140+
wrapper, NULL);
21402141
Py_DECREF(wrapper);
21412142
if (res == NULL) {
21422143
goto fail;

0 commit comments

Comments
 (0)