[Python-checkins] cpython (3.6): _asyncio uses _PyObject_CallMethodIdObjArgs()

victor.stinner python-checkins at python.org
Thu Dec 15 03:09:36 EST 2016


https://hg.python.org/cpython/rev/f2745b64d8b7
changeset: 105632:f2745b64d8b7
branch: 3.6
parent: 105630:502f5d53fb4a
user: Victor Stinner <victor.stinner at gmail.com>
date: Thu Dec 15 09:05:11 2016 +0100
summary:
 _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).
files:
 Modules/_asynciomodule.c | 19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -1327,7 +1327,7 @@
 return -1;
 }
 
- res = _PyObject_CallMethodId(all_tasks, &PyId_add, "O", self, NULL);
+ res = _PyObject_CallMethodIdObjArgs(all_tasks, &PyId_add, self, NULL);
 if (res == NULL) {
 return -1;
 }
@@ -1838,8 +1838,8 @@
 }
 else {
 /* `task` is a subclass of Task */
- return _PyObject_CallMethodId(
- (PyObject*)task, &PyId__wakeup, "O", fut, NULL);
+ return _PyObject_CallMethodIdObjArgs((PyObject*)task, &PyId__wakeup,
+ fut, NULL);
 }
 }
 
@@ -1854,8 +1854,8 @@
 if (arg == NULL) {
 arg = Py_None;
 }
- return _PyObject_CallMethodId(
- (PyObject*)task, &PyId__step, "O", arg, NULL);
+ return _PyObject_CallMethodIdObjArgs((PyObject*)task, &PyId__step,
+ arg, NULL);
 }
 }
 
@@ -1869,8 +1869,8 @@
 return -1;
 }
 
- handle = _PyObject_CallMethodId(
- task->task_loop, &PyId_call_soon, "O", cb, NULL);
+ handle = _PyObject_CallMethodIdObjArgs(task->task_loop, &PyId_call_soon,
+ cb, NULL);
 Py_DECREF(cb);
 if (handle == NULL) {
 return -1;
@@ -2135,8 +2135,9 @@
 if (wrapper == NULL) {
 goto fail;
 }
- res = _PyObject_CallMethodId(
- result, &PyId_add_done_callback, "O", wrapper, NULL);
+ res = _PyObject_CallMethodIdObjArgs(result,
+ &PyId_add_done_callback,
+ wrapper, NULL);
 Py_DECREF(wrapper);
 if (res == NULL) {
 goto fail;
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /