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 /Lib | |
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 'Lib')
-rw-r--r-- | Lib/asyncio/futures.py | 3 | ||||
-rw-r--r-- | Lib/asyncio/queues.py | 3 | ||||
-rw-r--r-- | Lib/asyncio/tasks.py | 3 |
3 files changed, 9 insertions, 0 deletions
diff --git a/Lib/asyncio/futures.py b/Lib/asyncio/futures.py index 9afda22..a3cf379 100644 --- a/Lib/asyncio/futures.py +++ b/Lib/asyncio/futures.py @@ -103,6 +103,9 @@ class Future: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) + def __class_getitem__(cls, type): + return cls + @property def _log_traceback(self): return self.__log_traceback diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py index 390ae9a..cd3f7c6 100644 --- a/Lib/asyncio/queues.py +++ b/Lib/asyncio/queues.py @@ -76,6 +76,9 @@ class Queue: def __str__(self): return f'<{type(self).__name__} {self._format()}>' + def __class_getitem__(cls, type): + return cls + def _format(self): result = f'maxsize={self._maxsize!r}' if getattr(self, '_queue', None): diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py index 38d9827..894d28e 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -175,6 +175,9 @@ class Task(futures._PyFuture): # Inherit Python Task implementation self._loop.call_exception_handler(context) super().__del__() + def __class_getitem__(cls, type): + return cls + def _repr_info(self): return base_tasks._task_repr_info(self) |