File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed
Misc/NEWS.d/next/Core_and_Builtins Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -2637,6 +2637,30 @@ def f2():
26372637
26382638 f2 ()
26392639
2640+ def test_next_instr_for_exception_handler_set (self ):
2641+ # gh-140104: We just want the exception to be caught properly.
2642+ def f ():
2643+ for i in range (TIER2_THRESHOLD + 3 ):
2644+ try :
2645+ undefined_variable (i )
2646+ except Exception :
2647+ pass
2648+
2649+ f ()
2650+
2651+ def test_next_instr_for_exception_handler_set_lasts_instr (self ):
2652+ # gh-140104: We just want the exception to be caught properly.
2653+ def f ():
2654+ a_list = []
2655+ for _ in range (TIER2_THRESHOLD + 3 ):
2656+ try :
2657+ a_list ["" ] = 0
2658+ except Exception :
2659+ pass
2660+
2661+ f ()
2662+
2663+
26402664
26412665def global_identity (x ):
26422666 return x
Original file line number Diff line number Diff line change 1+ Fix a bug with exception handling in the JIT. Patch by Ken Jin. Bug reported
2+ by Daniel Diniz.
Original file line number Diff line number Diff line change @@ -358,7 +358,9 @@ do { \
358358 frame = tstate->current_frame; \
359359 stack_pointer = _PyFrame_GetStackPointer(frame); \
360360 if (next_instr == NULL) { \
361- next_instr = frame->instr_ptr; \
361+ /* gh-140104: The exception handler expects frame->instr_ptr
362+ to after this_instr, not this_instr! */ \
363+ next_instr = frame -> instr_ptr + 1 ; \
362364 JUMP_TO_LABEL (error ); \
363365 } \
364366 DISPATCH (); \
You can’t perform that action at this time.
0 commit comments