diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2016-03-02 16:03:28 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2016-03-02 16:03:28 (GMT) |
commit | 1bd030788d1092ba5d5d8b4e2fd75346ded69b3b (patch) | |
tree | a4b2f9a091fa43918685ad0621300697e52ace97 /Lib/asyncio | |
parent | dce63234c55db7395ccc62d5e6e96c19696871e8 (diff) | |
download | cpython-1bd030788d1092ba5d5d8b4e2fd75346ded69b3b.zip cpython-1bd030788d1092ba5d5d8b4e2fd75346ded69b3b.tar.gz cpython-1bd030788d1092ba5d5d8b4e2fd75346ded69b3b.tar.bz2 |
asyncio: Prevent StopIteration from being thrown into a Future
Patch by Chris Angelico (issue #26221)
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/futures.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/asyncio/futures.py b/Lib/asyncio/futures.py index 281fea3..ddb9cde 100644 --- a/Lib/asyncio/futures.py +++ b/Lib/asyncio/futures.py @@ -341,6 +341,9 @@ class Future: raise InvalidStateError('{}: {!r}'.format(self._state, self)) if isinstance(exception, type): exception = exception() + if type(exception) is StopIteration: + raise TypeError("StopIteration interacts badly with generators " + "and cannot be raised into a Future") self._exception = exception self._state = _FINISHED self._schedule_callbacks() |