diff options
author | Yury Selivanov <yselivanov@gmail.com> | 2017-03-03 04:46:56 (GMT) |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2017-03-03 05:05:22 (GMT) |
commit | d8b72e4a0673c414120b029065dbe77055f12e82 (patch) | |
tree | 3a7d52223b4f85ce5f23dd9b1c190fe480b53d56 /Lib/test/test_asyncio/test_futures.py | |
parent | 2ef08d3be780457c444741b67e6181675b044be9 (diff) | |
download | cpython-d8b72e4a0673c414120b029065dbe77055f12e82.zip cpython-d8b72e4a0673c414120b029065dbe77055f12e82.tar.gz cpython-d8b72e4a0673c414120b029065dbe77055f12e82.tar.bz2 |
bpo-28963: Fix out of bound iteration in asyncio.Future.remove_done_callback/C (#408)
Diffstat (limited to 'Lib/test/test_asyncio/test_futures.py')
-rw-r--r-- | Lib/test/test_asyncio/test_futures.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_futures.py b/Lib/test/test_asyncio/test_futures.py index 89afdca..99336f8 100644 --- a/Lib/test/test_asyncio/test_futures.py +++ b/Lib/test/test_asyncio/test_futures.py @@ -569,6 +569,35 @@ class BaseFutureDoneCallbackTests(): self.assertEqual(bag, [2]) self.assertEqual(f.result(), 'foo') + def test_remove_done_callbacks_list_mutation(self): + # see http://bugs.python.org/issue28963 for details + + fut = self._new_future() + fut.add_done_callback(str) + + for _ in range(63): + fut.add_done_callback(id) + + class evil: + def __eq__(self, other): + fut.remove_done_callback(id) + return False + + fut.remove_done_callback(evil()) + + def test_schedule_callbacks_list_mutation(self): + # see http://bugs.python.org/issue28963 for details + + def mut(f): + f.remove_done_callback(str) + + fut = self._new_future() + fut.add_done_callback(mut) + fut.add_done_callback(str) + fut.add_done_callback(str) + fut.set_result(1) + test_utils.run_briefly(self.loop) + @unittest.skipUnless(hasattr(futures, '_CFuture'), 'requires the C _asyncio module') |