File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 11import dis
2+ import gc
23from itertools import combinations , product
34import opcode
45import sys
@@ -2613,6 +2614,22 @@ def test_send(self):
26132614 ]
26142615 self .cfg_optimization_test (insts , expected , consts = [None ])
26152616
2617+ def test_del_in_finally (self ):
2618+ # This loads `obj` onto the stack, executes `del obj`, then returns the
2619+ # `obj` from the stack. See gh-133371 for more details.
2620+ def create_obj ():
2621+ obj = [42 ]
2622+ try :
2623+ return obj
2624+ finally :
2625+ del obj
2626+
2627+ obj = create_obj ()
2628+ # The crash in the linked issue happens while running GC during
2629+ # interpreter finalization, so run it here manually.
2630+ gc .collect ()
2631+ self .assertEqual (obj , [42 ])
2632+
26162633
26172634
26182635if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments