77import weakref
88import errno
99
10- from test .support import (TESTFN , unlink , run_unittest , captured_output ,
11- check_warnings , gc_collect , cpython_only , no_tracing )
10+ from test .support import (TESTFN , captured_output , check_impl_detail ,
11+ check_warnings , cpython_only , gc_collect , run_unittest ,
12+ no_tracing , unlink )
1213
1314class NaiveException (Exception ):
1415 def __init__ (self , x ):
@@ -551,7 +552,9 @@ def inner_raising_func():
551552 e .__context__ = None
552553 obj = None
553554 obj = wr ()
554- gc_collect ()
555+ # guarantee no ref cycles on CPython (don't gc_collect)
556+ if check_impl_detail (cpython = False ):
557+ gc_collect ()
555558 self .assertTrue (obj is None , "%s" % obj )
556559
557560 # Some complicated construct
@@ -568,7 +571,8 @@ def inner_raising_func():
568571 except MyException :
569572 pass
570573 obj = None
571- gc_collect ()
574+ if check_impl_detail (cpython = False ):
575+ gc_collect ()
572576 obj = wr ()
573577 self .assertTrue (obj is None , "%s" % obj )
574578
@@ -583,7 +587,8 @@ def __exit__ (self, exc_type, exc_value, exc_tb):
583587 with Context ():
584588 inner_raising_func ()
585589 obj = None
586- gc_collect ()
590+ if check_impl_detail (cpython = False ):
591+ gc_collect ()
587592 obj = wr ()
588593 self .assertTrue (obj is None , "%s" % obj )
589594
0 commit comments