summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/futures.py
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2017-12-25 15:48:15 (GMT)
committerGitHub <noreply@github.com>2017-12-25 15:48:15 (GMT)
commit0cf16f9ea014b17d398ee3971d4976c698533318 (patch)
treec0a2ec1cc06a2519ea5b8a254de844ec1afb3955 /Lib/asyncio/futures.py
parent3dfbaf51f0d90646e0414ddbd3b513ee8e5ffe9b (diff)
downloadcpython-0cf16f9ea014b17d398ee3971d4976c698533318.zip
cpython-0cf16f9ea014b17d398ee3971d4976c698533318.tar.gz
cpython-0cf16f9ea014b17d398ee3971d4976c698533318.tar.bz2
bpo-32363: Disable Task.set_exception() and Task.set_result() (#4923)
Diffstat (limited to 'Lib/asyncio/futures.py')
-rw-r--r--Lib/asyncio/futures.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/asyncio/futures.py b/Lib/asyncio/futures.py
index 24843c0..13fb47c 100644
--- a/Lib/asyncio/futures.py
+++ b/Lib/asyncio/futures.py
@@ -239,14 +239,15 @@ class Future:
self._schedule_callbacks()
self._log_traceback = True
- def __iter__(self):
+ def __await__(self):
if not self.done():
self._asyncio_future_blocking = True
yield self # This tells Task to wait for completion.
- assert self.done(), "await wasn't used with future"
+ if not self.done():
+ raise RuntimeError("await wasn't used with future")
return self.result() # May raise too.
- __await__ = __iter__ # make compatible with 'await' expression
+ __iter__ = __await__ # make compatible with 'yield from'.
# Needed for testing purposes.