@@ -3887,9 +3887,12 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
3887
3887
*/
3888
3888
f -> f_stacktop = stack_pointer ;
3889
3889
3890
- /* the -1 is to adjust for the f_lasti change.
3891
- (look for the word 'Promise' above) */
3892
- f -> f_lasti = INSTR_OFFSET () - 2 ;
3890
+ /* Set f->f_lasti to the instruction before the current one or to the
3891
+ * first instruction (-1). See "f->f_lasti refers to ..." above.
3892
+ */
3893
+ f -> f_lasti = INSTR_OFFSET () ?
3894
+ assert (INSTR_OFFSET () >= sizeof (_Py_CODEUNIT )),
3895
+ (int )(INSTR_OFFSET () - sizeof (_Py_CODEUNIT )) : -1 ;
3893
3896
if (SLP_PEEK_NEXT_FRAME (tstate )-> f_back != f )
3894
3897
return retval ;
3895
3898
STACKLESS_UNPACK (tstate , retval );
@@ -3935,9 +3938,12 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
3935
3938
f -> f_execute = slp_eval_frame_noval ;
3936
3939
f -> f_stacktop = stack_pointer ;
3937
3940
3938
- /* the -1 is to adjust for the f_lasti change.
3939
- (look for the word 'Promise' above) */
3940
- f -> f_lasti = INSTR_OFFSET () - 2 ;
3941
+ /* Set f->f_lasti to the instruction before the current one or to the
3942
+ * first instruction (-1). See "f->f_lasti refers to ..." above.
3943
+ */
3944
+ f -> f_lasti = INSTR_OFFSET () ?
3945
+ assert (INSTR_OFFSET () >= sizeof (_Py_CODEUNIT )),
3946
+ (int )(INSTR_OFFSET () - sizeof (_Py_CODEUNIT )) : -1 ;
3941
3947
return (PyObject * ) Py_UnwindToken ;
3942
3948
#endif
3943
3949
}
0 commit comments