Skip to content

Commit 0d91488

Browse files
pythongh-118414: Fix assertion in YIELD_VALUE when tracing lines or instrs (python#118683)
1 parent b2cd54a commit 0d91488

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

Lib/test/test_monitoring.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,17 @@ def func2():
656656

657657
self.check_lines(func2, [1,2,3,4,5,6])
658658

659+
def test_generator_with_line(self):
660+
661+
def f():
662+
def a():
663+
yield
664+
def b():
665+
yield from a()
666+
next(b())
667+
668+
self.check_lines(f, [1,3,5,4,2,4])
669+
659670
class TestDisable(MonitoringTestBase, unittest.TestCase):
660671

661672
def gen(self, cond):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add instrumented opcodes to YIELD_VALUE assertion for tracing cases.

Python/bytecodes.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,9 @@ dummy_func(
11211121
/* We don't know which of these is relevant here, so keep them equal */
11221122
assert(INLINE_CACHE_ENTRIES_SEND == INLINE_CACHE_ENTRIES_FOR_ITER);
11231123
#if TIER_ONE
1124-
assert(_PyOpcode_Deopt[frame->instr_ptr->op.code] == SEND ||
1124+
assert(frame->instr_ptr->op.code == INSTRUMENTED_LINE ||
1125+
frame->instr_ptr->op.code == INSTRUMENTED_INSTRUCTION ||
1126+
_PyOpcode_Deopt[frame->instr_ptr->op.code] == SEND ||
11251127
_PyOpcode_Deopt[frame->instr_ptr->op.code] == FOR_ITER ||
11261128
_PyOpcode_Deopt[frame->instr_ptr->op.code] == INTERPRETER_EXIT ||
11271129
_PyOpcode_Deopt[frame->instr_ptr->op.code] == ENTER_EXECUTOR);

Python/executor_cases.c.h

Lines changed: 3 additions & 1 deletion
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: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)