@@ -605,7 +605,7 @@ visit_reachable(PyObject *op, void *arg)
605605 // This also skips objects "to the left" of the current position in
606606 // move_unreachable's scan of the 'young' list - they've already been
607607 // traversed, and no longer have the PREV_MASK_COLLECTING flag.
608- if (! gc_is_collecting (gc )) {
608+ if (!gc_is_collecting (gc )) {
609609 return 0 ;
610610 }
611611 // It would be a logic error elsewhere if the collecting flag were set on
@@ -1372,18 +1372,21 @@ struct container_and_flag {
13721372static int
13731373visit_add_to_container (PyObject * op , void * arg )
13741374{
1375+ if (!_PyObject_GC_IS_TRACKED (op )) {
1376+ return 0 ;
1377+ }
1378+ if (_Py_IsImmortal (op )) {
1379+ return 0 ;
1380+ }
13751381 OBJECT_STAT_INC (object_visits );
13761382 struct container_and_flag * cf = (struct container_and_flag * )arg ;
13771383 int visited = cf -> visited_space ;
13781384 assert (visited == get_gc_state ()-> visited_space );
1379- if (!_Py_IsImmortal (op ) && _PyObject_IS_GC (op )) {
1380- PyGC_Head * gc = AS_GC (op );
1381- if (_PyObject_GC_IS_TRACKED (op ) &&
1382- gc_old_space (gc ) != visited ) {
1383- gc_flip_old_space (gc );
1384- gc_list_move (gc , cf -> container );
1385- cf -> size ++ ;
1386- }
1385+ PyGC_Head * gc = AS_GC (op );
1386+ if (gc_old_space (gc ) != visited ) {
1387+ gc_flip_old_space (gc );
1388+ gc_list_move (gc , cf -> container );
1389+ cf -> size ++ ;
13871390 }
13881391 return 0 ;
13891392}
0 commit comments