asyncio: Prevent StopIteration from being thrown into a Future

Patch by Chris Angelico (issue #26221)
This commit is contained in:
Yury Selivanov 2016-03-02 11:03:28 -05:00
parent dce63234c5
commit 1bd030788d
2 changed files with 7 additions and 0 deletions

View file

@ -76,6 +76,10 @@ class FutureTests(test_utils.TestCase):
f = asyncio.Future(loop=self.loop)
self.assertRaises(asyncio.InvalidStateError, f.exception)
# StopIteration cannot be raised into a Future - CPython issue26221
self.assertRaisesRegex(TypeError, "StopIteration .* cannot be raised",
f.set_exception, StopIteration)
f.set_exception(exc)
self.assertFalse(f.cancelled())
self.assertTrue(f.done())