Skip to content

Commit 8fb54fa

Browse files
committed
fix get_tools_for_instruction
1 parent 3b8e1d5 commit 8fb54fa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Python/instrumentation.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,10 +1104,18 @@ get_tools_for_instruction(PyCodeObject *code, PyInterpreterState *interp, int i,
11041104
}
11051105
assert(_PY_MONITORING_IS_UNGROUPED_EVENT(event));
11061106
CHECK(debug_check_sanity(interp, code));
1107-
if (code->_co_monitoring->tools) {
1108-
tools = code->_co_monitoring->tools[i];
1107+
if (PY_MONITORING_IS_INSTRUMENTED_EVENT(event)) {
1108+
/* Instrumented events use per-instruction tool bitmaps. */
1109+
if (code->_co_monitoring->tools) {
1110+
tools = code->_co_monitoring->tools[i];
1111+
}
1112+
else {
1113+
tools = code->_co_monitoring->active_monitors.tools[event];
1114+
}
11091115
}
11101116
else {
1117+
/* Non-instrumented local events are not tied to specific instructions;
1118+
* use the code-object-level active_monitors bitmap instead. */
11111119
tools = code->_co_monitoring->active_monitors.tools[event];
11121120
}
11131121
return tools;

0 commit comments

Comments
 (0)