diff options
author | Mark Shannon <mark@hotpy.org> | 2024-12-19 16:59:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-19 16:59:51 (GMT) |
commit | d2f1d917e8b3d2dd8f35495c7632a32688883332 (patch) | |
tree | 334558f483e0f41d80924973d16b68354bf95b82 /Python/codegen.c | |
parent | 7b811d0562a0bf7433165785f1549ac199610f8b (diff) | |
download | cpython-d2f1d917e8b3d2dd8f35495c7632a32688883332.zip cpython-d2f1d917e8b3d2dd8f35495c7632a32688883332.tar.gz cpython-d2f1d917e8b3d2dd8f35495c7632a32688883332.tar.bz2 |
GH-122548: Implement branch taken and not taken events for sys.monitoring (GH-122564)
Diffstat (limited to 'Python/codegen.c')
-rw-r--r-- | Python/codegen.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Python/codegen.c b/Python/codegen.c index a5e550c..6d3272e 100644 --- a/Python/codegen.c +++ b/Python/codegen.c @@ -406,7 +406,13 @@ codegen_addop_j(instr_sequence *seq, location loc, assert(IS_JUMP_TARGET_LABEL(target)); assert(OPCODE_HAS_JUMP(opcode) || IS_BLOCK_PUSH_OPCODE(opcode)); assert(!IS_ASSEMBLER_OPCODE(opcode)); - return _PyInstructionSequence_Addop(seq, opcode, target.id, loc); + if (_PyInstructionSequence_Addop(seq, opcode, target.id, loc) != SUCCESS) { + return ERROR; + } + if (IS_CONDITIONAL_JUMP_OPCODE(opcode) || opcode == FOR_ITER) { + return _PyInstructionSequence_Addop(seq, NOT_TAKEN, 0, NO_LOCATION); + } + return SUCCESS; } #define ADDOP_JUMP(C, LOC, OP, O) \ @@ -682,7 +688,6 @@ codegen_setup_annotations_scope(compiler *c, location loc, ADDOP_I(c, loc, COMPARE_OP, (Py_GT << 5) | compare_masks[Py_GT]); NEW_JUMP_TARGET_LABEL(c, body); ADDOP_JUMP(c, loc, POP_JUMP_IF_FALSE, body); - ADDOP_I(c, loc, LOAD_COMMON_CONSTANT, CONSTANT_NOTIMPLEMENTEDERROR); ADDOP_I(c, loc, RAISE_VARARGS, 1); USE_LABEL(c, body); |