summaryrefslogtreecommitdiffstats
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-11-02 10:18:43 (GMT)
committerGitHub <noreply@github.com>2023-11-02 10:18:43 (GMT)
commit52cc4af6ae9002f11605f91b672746c127494efd (patch)
tree1bb4c679b3e179fdb9ccbacff4316c98fd594e79 /Python/bytecodes.c
parent970e719a7a829bddc647bbaa668dd8603abdddef (diff)
downloadcpython-52cc4af6ae9002f11605f91b672746c127494efd.zip
cpython-52cc4af6ae9002f11605f91b672746c127494efd.tar.gz
cpython-52cc4af6ae9002f11605f91b672746c127494efd.tar.bz2
gh-111354: simplify detection of RESUME after YIELD_VALUE at except-depth 1 (#111459)
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 9aca82a..9f1dfa3 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -149,7 +149,7 @@ dummy_func(
next_instr = this_instr;
}
else {
- if (oparg < RESUME_AFTER_YIELD_FROM) {
+ if ((oparg & RESUME_OPARG_LOCATION_MASK) < RESUME_AFTER_YIELD_FROM) {
CHECK_EVAL_BREAKER();
}
this_instr->op.code = RESUME_CHECK;
@@ -177,7 +177,7 @@ dummy_func(
next_instr = this_instr;
}
else {
- if (oparg < 2) {
+ if ((oparg & RESUME_OPARG_LOCATION_MASK) < RESUME_AFTER_YIELD_FROM) {
CHECK_EVAL_BREAKER();
}
_PyFrame_SetStackPointer(frame, stack_pointer);
@@ -1047,7 +1047,6 @@ dummy_func(
inst(INSTRUMENTED_YIELD_VALUE, (retval -- unused)) {
assert(frame != &entry_frame);
- assert(oparg >= 0); /* make the generator identify this as HAS_ARG */
frame->instr_ptr = next_instr;
PyGenObject *gen = _PyFrame_GetGenerator(frame);
gen->gi_frame_state = FRAME_SUSPENDED;
@@ -1073,7 +1072,6 @@ dummy_func(
// NOTE: It's important that YIELD_VALUE never raises an exception!
// The compiler treats any exception raised here as a failed close()
// or throw() call.
- assert(oparg >= 0); /* make the generator identify this as HAS_ARG */
assert(frame != &entry_frame);
frame->instr_ptr = next_instr;
PyGenObject *gen = _PyFrame_GetGenerator(frame);