bpo-36999: Add asyncio.Task.get_coro() (GH-13680)

https://bugs.python.org/issue36999
This commit is contained in:
Alex Grönholm 2019-05-30 18:30:09 +03:00 committed by Miss Islington (bot)
parent 25ee0c3bf1
commit 98ef92002e
6 changed files with 52 additions and 1 deletions

View file

@ -2313,6 +2313,18 @@ _asyncio_Task_set_exception(TaskObj *self, PyObject *exception)
return NULL;
}
/*[clinic input]
_asyncio.Task.get_coro
[clinic start generated code]*/
static PyObject *
_asyncio_Task_get_coro_impl(TaskObj *self)
/*[clinic end generated code: output=bcac27c8cc6c8073 input=d2e8606c42a7b403]*/
{
Py_INCREF(self->task_coro);
return self->task_coro;
}
/*[clinic input]
_asyncio.Task.get_name
[clinic start generated code]*/
@ -2439,6 +2451,7 @@ static PyMethodDef TaskType_methods[] = {
_ASYNCIO_TASK__REPR_INFO_METHODDEF
_ASYNCIO_TASK_GET_NAME_METHODDEF
_ASYNCIO_TASK_SET_NAME_METHODDEF
_ASYNCIO_TASK_GET_CORO_METHODDEF
{NULL, NULL} /* Sentinel */
};

View file

@ -569,6 +569,23 @@ PyDoc_STRVAR(_asyncio_Task_set_exception__doc__,
#define _ASYNCIO_TASK_SET_EXCEPTION_METHODDEF \
{"set_exception", (PyCFunction)_asyncio_Task_set_exception, METH_O, _asyncio_Task_set_exception__doc__},
PyDoc_STRVAR(_asyncio_Task_get_coro__doc__,
"get_coro($self, /)\n"
"--\n"
"\n");
#define _ASYNCIO_TASK_GET_CORO_METHODDEF \
{"get_coro", (PyCFunction)_asyncio_Task_get_coro, METH_NOARGS, _asyncio_Task_get_coro__doc__},
static PyObject *
_asyncio_Task_get_coro_impl(TaskObj *self);
static PyObject *
_asyncio_Task_get_coro(TaskObj *self, PyObject *Py_UNUSED(ignored))
{
return _asyncio_Task_get_coro_impl(self);
}
PyDoc_STRVAR(_asyncio_Task_get_name__doc__,
"get_name($self, /)\n"
"--\n"
@ -815,4 +832,4 @@ _asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs,
exit:
return return_value;
}
/*[clinic end generated code: output=e3b02d96da56e80c input=a9049054013a1b77]*/
/*[clinic end generated code: output=51c50219f6a0863a input=a9049054013a1b77]*/