File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -357,6 +357,9 @@ def f():
357357 code = f .__code__
358358 a = []
359359 code = code .replace (co_consts = code .co_consts + (a ,))
360+ # This test creates a reference loop which leads to reference leaks,
361+ # so we need to break the loop manually. See gh-148722.
362+ self .addCleanup (a .clear )
360363 a .append (code )
361364 for v in range (marshal .version + 1 ):
362365 self .assertRaises (ValueError , marshal .dumps , code , v )
@@ -404,10 +407,12 @@ def test_loads_abnormal_reference_loops(self):
404407 self .assertIs (a [0 ][None ], a )
405408
406409 # Direct self-reference which cannot be created in Python.
407- data = b'\xa8 \x01 \x00 \x00 \x00 r\x00 \x00 \x00 \x00 ' # (<R>,)
408- a = marshal .loads (data )
409- self .assertIsInstance (a , tuple )
410- self .assertIs (a [0 ], a )
410+ # This creates a reference loop which cannot be collected.
411+ if False :
412+ data = b'\xa8 \x01 \x00 \x00 \x00 r\x00 \x00 \x00 \x00 ' # (<R>,)
413+ a = marshal .loads (data )
414+ self .assertIsInstance (a , tuple )
415+ self .assertIs (a [0 ], a )
411416
412417 # Direct self-references which cannot be created in Python
413418 # because of unhashability.
You can’t perform that action at this time.
0 commit comments