diff options
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r-- | Objects/genobject.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c index cdb2a0f76b0..e58118b2694 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -352,14 +352,14 @@ _PyGen_yf(PyGenObject *gen) if (gen->gi_frame_state < FRAME_CLEARED) { _PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe; - if (frame->f_lasti < 1) { + if (gen->gi_frame_state == FRAME_CREATED) { /* Return immediately if the frame didn't start yet. SEND always come after LOAD_CONST: a code object should not start with SEND */ assert(_Py_OPCODE(_PyCode_CODE(gen->gi_code)[0]) != SEND); return NULL; } - _Py_CODEUNIT next = _PyCode_CODE(gen->gi_code)[frame->f_lasti + 1]; + _Py_CODEUNIT next = frame->prev_instr[1]; if (_PyOpcode_Deopt[_Py_OPCODE(next)] != RESUME || _Py_OPARG(next) < 2) { /* Not in a yield from */ @@ -490,13 +490,11 @@ _gen_throw(PyGenObject *gen, int close_on_genexit, // XXX: Performing this jump ourselves is awkward and problematic. // See https://github.com/python/cpython/pull/31968. /* Termination repetition of SEND loop */ - assert(frame->f_lasti >= 0); - _Py_CODEUNIT *code = _PyCode_CODE(gen->gi_code); + assert(_PyInterpreterFrame_LASTI(frame) >= 0); /* Backup to SEND */ - frame->f_lasti--; - assert(_Py_OPCODE(code[frame->f_lasti]) == SEND); - int jump = _Py_OPARG(code[frame->f_lasti]); - frame->f_lasti += jump; + assert(_Py_OPCODE(frame->prev_instr[-1]) == SEND); + int jump = _Py_OPARG(frame->prev_instr[-1]); + frame->prev_instr += jump - 1; if (_PyGen_FetchStopIterationValue(&val) == 0) { ret = gen_send(gen, val); Py_DECREF(val); @@ -1344,9 +1342,8 @@ compute_cr_origin(int origin_depth, _PyInterpreterFrame *current_frame) frame = current_frame; for (int i = 0; i < frame_count; ++i) { PyCodeObject *code = frame->f_code; - PyObject *frameinfo = Py_BuildValue("OiO", - code->co_filename, - PyCode_Addr2Line(frame->f_code, frame->f_lasti*sizeof(_Py_CODEUNIT)), + int line = _PyInterpreterFrame_GetLine(frame); + PyObject *frameinfo = Py_BuildValue("OiO", code->co_filename, line, code->co_name); if (!frameinfo) { Py_DECREF(cr_origin); |