diff options
author | Batuhan Taşkaya <47358913+isidentical@users.noreply.github.com> | 2019-12-07 11:05:07 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-12-07 11:05:07 (GMT) |
commit | dec367261e7e2bb4dd42feeb58031abed2ade683 (patch) | |
tree | d1d7debbc9f5fc199d8f632d8042b9c628a5a5ce /Modules | |
parent | 723f71abf7ab0a7be394f9f7b2daa9ecdf6fb1eb (diff) | |
download | cpython-dec367261e7e2bb4dd42feeb58031abed2ade683.zip cpython-dec367261e7e2bb4dd42feeb58031abed2ade683.tar.gz cpython-dec367261e7e2bb4dd42feeb58031abed2ade683.tar.bz2 |
bpo-38978: Implement __class_getitem__ for asyncio objects (GH-17491)
https://bugs.python.org/issue38978
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_asynciomodule.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index aa46e3c..2d14744 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -1381,6 +1381,12 @@ finally: PyErr_Restore(error_type, error_value, error_traceback); } +static PyObject * +future_cls_getitem(PyObject *cls, PyObject *type) +{ + Py_INCREF(cls); + return cls; +} static PyAsyncMethods FutureType_as_async = { (unaryfunc)future_new_iter, /* am_await */ @@ -1400,6 +1406,7 @@ static PyMethodDef FutureType_methods[] = { _ASYNCIO_FUTURE_DONE_METHODDEF _ASYNCIO_FUTURE_GET_LOOP_METHODDEF _ASYNCIO_FUTURE__REPR_INFO_METHODDEF + {"__class_getitem__", future_cls_getitem, METH_O|METH_CLASS, NULL}, {NULL, NULL} /* Sentinel */ }; @@ -2429,6 +2436,13 @@ done: FutureObj_finalize((FutureObj*)task); } +static PyObject * +task_cls_getitem(PyObject *cls, PyObject *type) +{ + Py_INCREF(cls); + return cls; +} + static void TaskObj_dealloc(PyObject *); /* Needs Task_CheckExact */ static PyMethodDef TaskType_methods[] = { @@ -2449,6 +2463,7 @@ static PyMethodDef TaskType_methods[] = { _ASYNCIO_TASK_GET_NAME_METHODDEF _ASYNCIO_TASK_SET_NAME_METHODDEF _ASYNCIO_TASK_GET_CORO_METHODDEF + {"__class_getitem__", task_cls_getitem, METH_O|METH_CLASS, NULL}, {NULL, NULL} /* Sentinel */ }; |