File tree Expand file tree Collapse file tree
Lib/test/test_concurrent_futures Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ):
You can’t perform that action at this time.
0 commit comments