Skip to content

Commit 952784a

Browse files
gh-137030: Fix YIELD_VALUE bytecode assertion (#149184)
Co-authored-by: Mark Shannon <mark@hotpy.org>
1 parent 6ca5cdb commit 952784a

7 files changed

Lines changed: 44 additions & 45 deletions

File tree

Include/internal/pycore_code.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@ typedef struct {
539539

540540
PyAPI_FUNC(int) _Py_Instrument(PyCodeObject *co, PyInterpreterState *interp);
541541

542-
extern _Py_CODEUNIT _Py_GetBaseCodeUnit(PyCodeObject *code, int offset);
542+
// Export for '_testinternalcapi' shared extension
543+
PyAPI_FUNC(_Py_CODEUNIT) _Py_GetBaseCodeUnit(PyCodeObject *code, int offset);
543544

544545
extern int _PyInstruction_GetLength(PyCodeObject *code, int offset);
545546

Include/internal/pycore_opcode_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_testinternalcapi/test_cases.c.h

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,13 +1770,12 @@ dummy_func(
17701770
FT_ATOMIC_STORE_INT8_RELEASE(gen->gi_frame_state, FRAME_SUSPENDED + oparg);
17711771
/* We don't know which of these is relevant here, so keep them equal */
17721772
assert(INLINE_CACHE_ENTRIES_SEND == INLINE_CACHE_ENTRIES_FOR_ITER);
1773-
#if TIER_ONE
1774-
assert(frame->instr_ptr->op.code == INSTRUMENTED_LINE ||
1775-
frame->instr_ptr->op.code == INSTRUMENTED_INSTRUCTION ||
1776-
_PyOpcode_Deopt[frame->instr_ptr->op.code] == SEND ||
1777-
_PyOpcode_Deopt[frame->instr_ptr->op.code] == FOR_ITER ||
1778-
_PyOpcode_Deopt[frame->instr_ptr->op.code] == INTERPRETER_EXIT ||
1779-
_PyOpcode_Deopt[frame->instr_ptr->op.code] == ENTER_EXECUTOR);
1773+
#if TIER_ONE && defined(Py_DEBUG)
1774+
if (!PyStackRef_IsNone(frame->f_executable)) {
1775+
int i = frame->instr_ptr - _PyFrame_GetBytecode(frame);
1776+
int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), i).op.code;
1777+
assert(opcode == SEND || opcode == FOR_ITER);
1778+
}
17801779
#endif
17811780
RELOAD_STACK();
17821781
LOAD_IP(1 + INLINE_CACHE_ENTRIES_SEND);

Python/executor_cases.c.h

Lines changed: 6 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)