summaryrefslogtreecommitdiffstats
path: root/Modules/_asynciomodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2022-10-05 06:49:10 (GMT)
committerGitHub <noreply@github.com>2022-10-05 06:49:10 (GMT)
commit8079bef56f2249ecedafe0be5a6d7a120a7f3ac3 (patch)
tree728a3afbab702ee4442a12d620ccd3e390a0a0ed /Modules/_asynciomodule.c
parentc70c8b69762f720377adaf22f2e5ec6496a7be53 (diff)
downloadcpython-8079bef56f2249ecedafe0be5a6d7a120a7f3ac3.zip
cpython-8079bef56f2249ecedafe0be5a6d7a120a7f3ac3.tar.gz
cpython-8079bef56f2249ecedafe0be5a6d7a120a7f3ac3.tar.bz2
GH-96704: Add {Task,Handle}.get_context(), use it in call_exception_handler() (#96756)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Diffstat (limited to 'Modules/_asynciomodule.c')
-rw-r--r--Modules/_asynciomodule.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 90917115..efa0d2d 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -2410,6 +2410,18 @@ _asyncio_Task_get_coro_impl(TaskObj *self)
}
/*[clinic input]
+_asyncio.Task.get_context
+[clinic start generated code]*/
+
+static PyObject *
+_asyncio_Task_get_context_impl(TaskObj *self)
+/*[clinic end generated code: output=6996f53d3dc01aef input=87c0b209b8fceeeb]*/
+{
+ Py_INCREF(self->task_context);
+ return self->task_context;
+}
+
+/*[clinic input]
_asyncio.Task.get_name
[clinic start generated code]*/
@@ -2536,6 +2548,7 @@ static PyMethodDef TaskType_methods[] = {
_ASYNCIO_TASK_GET_NAME_METHODDEF
_ASYNCIO_TASK_SET_NAME_METHODDEF
_ASYNCIO_TASK_GET_CORO_METHODDEF
+ _ASYNCIO_TASK_GET_CONTEXT_METHODDEF
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
{NULL, NULL} /* Sentinel */
};