bpo-31061: fix crash in asyncio speedup module (GH-2984) · python/cpython@f142e85 (original) (raw)

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
1 1 """Tests for futures.py."""
2 2
3 3 import concurrent.futures
4 +import gc
4 5 import re
5 6 import sys
6 7 import threading
@@ -19,9 +20,11 @@
19 20 def _fakefunc(f):
20 21 return f
21 22
23 +
22 24 def first_cb():
23 25 pass
24 26
27 +
25 28 def last_cb():
26 29 pass
27 30
@@ -483,6 +486,15 @@ def test_future_iter_throw(self):
483 486 Exception("elephant"), Exception("elephant"))
484 487 self.assertRaises(TypeError, fi.throw, list)
485 488
489 +def test_future_del_collect(self):
490 +class Evil:
491 +def __del__(self):
492 +gc.collect()
493 +
494 +for i in range(100):
495 +fut = self._new_future(loop=self.loop)
496 +fut.set_result(Evil())
497 +
486 498
487 499 @unittest.skipUnless(hasattr(futures, '_CFuture'),
488 500 'requires the C _asyncio module')