@@ -482,8 +482,7 @@ def __del__(self):
482482 x.x = x
483483 x.y = X('second')
484484 del x
485- if %d:
486- gc.set_debug(gc.DEBUG_UNCOLLECTABLE)
485+ gc.set_debug(%s)
487486 """
488487 def run_command (code ):
489488 p = subprocess .Popen ([sys .executable , "-c" , code ],
@@ -494,13 +493,19 @@ def run_command(code):
494493 self .assertEqual (stdout .strip (), b"" )
495494 return strip_python_stderr (stderr )
496495
497- stderr = run_command (code % 0 )
496+ stderr = run_command (code % "0" )
498497 self .assertIn (b"gc: 2 uncollectable objects at shutdown" , stderr )
499498 self .assertNotIn (b"[<X 'first'>, <X 'second'>]" , stderr )
500499 # With DEBUG_UNCOLLECTABLE, the garbage list gets printed
501- stderr = run_command (code % 1 )
500+ stderr = run_command (code % "gc.DEBUG_UNCOLLECTABLE" )
502501 self .assertIn (b"gc: 2 uncollectable objects at shutdown" , stderr )
503502 self .assertIn (b"[<X 'first'>, <X 'second'>]" , stderr )
503+ # With DEBUG_SAVEALL, no additional message should get printed
504+ # (because gc.garbage also contains normally reclaimable cyclic
505+ # references, and its elements get printed at runtime anyway).
506+ stderr = run_command (code % "gc.DEBUG_SAVEALL" )
507+ self .assertNotIn (b"uncollectable objects at shutdown" , stderr )
508+
504509
505510class GCTogglingTests (unittest .TestCase ):
506511 def setUp (self ):
0 commit comments