@@ -434,42 +434,6 @@ def run(self):
434434 tt .join ()
435435 self .assertEqual (LAST_FREED , 500 )
436436
437- @cpython_only
438- def test_clean_stack_on_return (self ):
439-
440- def f (x ):
441- return x
442-
443- code = f .__code__
444- ct = type (f .__code__ )
445-
446- # Insert an extra LOAD_FAST, this duplicates the value of
447- # 'x' in the stack, leaking it if the frame is not properly
448- # cleaned up upon exit.
449-
450- bytecode = list (code .co_code )
451- bytecode .insert (- 2 , opcode .opmap ['LOAD_FAST' ])
452- bytecode .insert (- 2 , 0 )
453-
454- c = ct (code .co_argcount , code .co_posonlyargcount ,
455- code .co_kwonlyargcount , code .co_nlocals , code .co_stacksize + 1 ,
456- code .co_flags , bytes (bytecode ),
457- code .co_consts , code .co_names , code .co_varnames ,
458- code .co_filename , code .co_name , code .co_firstlineno ,
459- code .co_lnotab , code .co_freevars , code .co_cellvars )
460- new_function = type (f )(c , f .__globals__ , 'nf' , f .__defaults__ , f .__closure__ )
461-
462- class Var :
463- pass
464- the_object = Var ()
465- var = weakref .ref (the_object )
466-
467- new_function (the_object )
468-
469- # Check if the_object is leaked
470- del the_object
471- assert var () is None
472-
473437
474438def test_main (verbose = None ):
475439 from test import test_code
0 commit comments