@@ -786,6 +786,7 @@ def cb(self, ignore):
786786
787787 del alist [:]
788788 gc .collect ()
789+ gc_collect () # <- GraalPy change
789790 self .assertEqual (alist , [])
790791
791792 def test_gc_during_ref_creation (self ):
@@ -798,6 +799,7 @@ def check_gc_during_creation(self, makeref):
798799 thresholds = gc .get_threshold ()
799800 gc .set_threshold (1 , 1 , 1 )
800801 gc .collect ()
802+ gc_collect () # <- GraalPy change
801803 class A :
802804 pass
803805
@@ -902,6 +904,7 @@ def test_ordering(self):
902904 # Same when dead.
903905 del x , y
904906 gc .collect ()
907+ gc_collect () # <- GraalPy change
905908 for op in ops :
906909 self .assertRaises (TypeError , op , a , b )
907910
@@ -914,6 +917,7 @@ def test_hashing(self):
914917 self .assertEqual (hash (a ), hash (42 ))
915918 del x , y
916919 gc .collect ()
920+ gc_collect () # <- GraalPy change
917921 # Dead weakrefs:
918922 # - retain their hash is they were hashed when alive;
919923 # - otherwise, cannot be hashed.
@@ -1192,6 +1196,7 @@ def _ne(a, b):
11921196 _eq (a , ALWAYS_EQ )
11931197 del x , y , z
11941198 gc .collect ()
1199+ gc_collect () # <- GraalPy change
11951200 # Dead WeakMethods compare by identity
11961201 refs = a , b , c , d , e , f
11971202 for q in refs :
@@ -1236,9 +1241,11 @@ def check_len_cycles(self, dict_type, cons):
12361241 pass
12371242 del items
12381243 gc .collect ()
1244+ gc_collect () # <- GraalPy change
12391245 n1 = len (dct )
12401246 del it
12411247 gc .collect ()
1248+ gc_collect () # <- GraalPy change
12421249 n2 = len (dct )
12431250 # one item may be kept alive inside the iterator
12441251 self .assertIn (n1 , (0 , 1 ))
@@ -1257,6 +1264,7 @@ def check_len_race(self, dict_type, cons):
12571264 for th in range (1 , 100 ):
12581265 N = 20
12591266 gc .collect (0 )
1267+ gc_collect () # <- GraalPy change
12601268 gc .set_threshold (th , th , th )
12611269 items = [RefCycle () for i in range (N )]
12621270 dct = dict_type (cons (o ) for o in items )
@@ -1428,6 +1436,7 @@ def check_weak_destroy_while_iterating(self, dict, objects, iter_name):
14281436 # Destroy an object
14291437 del objects [- 1 ]
14301438 gc .collect () # just in case
1439+ gc_collect () # <- GraalPy change
14311440 # We have removed either the first consumed object, or another one
14321441 self .assertIn (len (list (it )), [len (objects ), len (objects ) - 1 ])
14331442 del it
@@ -1508,10 +1517,12 @@ def testcontext():
15081517 # Schedule a key/value for removal and recreate it
15091518 v = objects .pop ().arg
15101519 gc .collect () # just in case
1520+ gc_collect () # <- GraalPy change
15111521 yield Object (v ), v
15121522 finally :
15131523 it = None # should commit all removals
15141524 gc .collect ()
1525+ gc_collect () # <- GraalPy change
15151526 self .check_weak_destroy_and_mutate_while_iterating (dict , testcontext )
15161527 # Issue #21173: len() fragile when keys are both implicitly and
15171528 # explicitly removed.
@@ -1535,10 +1546,12 @@ def testcontext():
15351546 # Schedule a key/value for removal and recreate it
15361547 k = objects .pop ().arg
15371548 gc .collect () # just in case
1549+ gc_collect () # <- GraalPy change
15381550 yield k , Object (k )
15391551 finally :
15401552 it = None # should commit all removals
15411553 gc .collect ()
1554+ gc_collect () # <- GraalPy change
15421555 self .check_weak_destroy_and_mutate_while_iterating (dict , testcontext )
15431556 dict , objects = self .make_weak_valued_dict ()
15441557 self .check_weak_del_and_len_while_iterating (dict , testcontext )
@@ -1907,6 +1920,7 @@ def pop_and_collect(lst):
19071920 lst .pop (i )
19081921 if gc_ctr % 10000 == 0 :
19091922 gc .collect () # just in case
1923+ gc_collect () # <- GraalPy change
19101924
19111925 self .assertIn (type_ , (weakref .WeakKeyDictionary , weakref .WeakValueDictionary ))
19121926
0 commit comments