gh-137030: Fix YIELD_VALUE bytecode assertion#149184
Open
vstinner wants to merge 2 commits intopython:mainfrom
Open
gh-137030: Fix YIELD_VALUE bytecode assertion#149184vstinner wants to merge 2 commits intopython:mainfrom
vstinner wants to merge 2 commits intopython:mainfrom
Conversation
Expect also INSTRUMENTED_FOR_ITER.
Member
Author
|
@Fidget-Spinner @markshannon @emmatyping: Would you mind to review this fix? See #137030 (comment) to reproduce the issue. |
Documentation build overview
16 files changed ·
|
markshannon
reviewed
Apr 30, 2026
| @@ -1781,6 +1781,7 @@ dummy_func( | |||
| #if TIER_ONE | |||
| assert(frame->instr_ptr->op.code == INSTRUMENTED_LINE || | |||
Member
There was a problem hiding this comment.
I'm not sure there's much value in this assert any more.
I'd be fine with removing the whole thing.
If you want to keep the check, this
Suggested change
| assert(frame->instr_ptr->op.code == INSTRUMENTED_LINE || | |
| #if TIER_ONE && defined(Py_DEBUG) | |
| if (!PyStackRef_IsNone(frame->f_executable)) { | |
| int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), frame->instr_ptr - _PyFrame_GetBytecode(frame)).op.code; | |
| assert(opcode == SEND || opcode == FOR_ITER); | |
| } | |
| #endif |
is probably a better formulation as it catches errors that would be hidden behind instrumentation.
Member
Author
There was a problem hiding this comment.
Ok, I updated my PR to use _Py_GetBaseCodeUnit().
Co-Authored-by: Mark Shannon <mark@hotpy.org>
Member
|
@emmatyping can you confirm that this fixes the issue? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Expect also INSTRUMENTED_FOR_ITER.