Skip to content

Commit 9bc69b9

Browse files
committed
test that traceback frames should not contain any variables referring to an Exception or a failed Future
1 parent 4dce280 commit 9bc69b9

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

Lib/test/test_concurrent_futures/executor.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,22 @@ def test_map_exception(self):
6767
msg="next one should raise a ZeroDivisionError",
6868
)
6969

70-
# a failed future should not be captured in its
71-
# future._exception.__traceback__ to avoid a reference cycle
72-
self.assertListEqual(gc.get_referrers(error), [])
70+
self.assertFalse(
71+
gc.get_referrers(error),
72+
msg="the raised error should not have any referrer",
73+
)
74+
75+
tb = error.__traceback__
76+
while (tb := tb.tb_next):
77+
self.assertFalse(
78+
{
79+
var: val
80+
for var, val in tb.tb_frame.f_locals.items()
81+
if isinstance(val, Exception)
82+
or (isinstance(val, futures.Future) and val.exception())
83+
},
84+
msg=f"traceback frames should not contain any variables referring to an Exception or a failed Future",
85+
)
7386

7487
@support.requires_resource('walltime')
7588
def test_map_timeout(self):

0 commit comments

Comments
 (0)