Skip to content

gh-142186: all-local PEP-669 events#146182

Draft
P403n1x87 wants to merge 5 commits intopython:mainfrom
P403n1x87:gh-142186-pep-669-all-local-events
Draft

gh-142186: all-local PEP-669 events#146182
P403n1x87 wants to merge 5 commits intopython:mainfrom
P403n1x87:gh-142186-pep-669-all-local-events

Conversation

@P403n1x87
Copy link
Contributor

@P403n1x87 P403n1x87 commented Mar 19, 2026

We make all the low-impact monitoring API events implemented by PEP-669 local on a per-code object basis. All the events can now be enabled on selected code objects. The distinction is now between instrumented and non-instrumented events, whereby the behaviour of the DISABLE sentinel value differs. For instrumented events, DISABLE will remove the instrumentation at the specific code location where the value was returned. For non-instrumented events, DISABLE will simply disable the event for the whole code object.


📚 Documentation preview 📚: https://cpython-previews--146182.org.readthedocs.build/

We make the PY_UNWIND monitoring event available as a code-local
event to allow trapping on function exit events when an exception
bubbles up. This complements the PY_RETURN event by allowing to
catch any function exit event.
We make all the events of the low-impact monitoring API local,
shifting the distinction to whether they are instrumented or
non-instrumented.
@P403n1x87 P403n1x87 force-pushed the gh-142186-pep-669-all-local-events branch from d02dc43 to 3b8e1d5 Compare March 19, 2026 18:18
Comment on lines +1105 to +1111
assert(_PY_MONITORING_IS_UNGROUPED_EVENT(event));
CHECK(debug_check_sanity(interp, code));
if (code->_co_monitoring->tools) {
tools = code->_co_monitoring->tools[i];
}
else {
tools = interp->monitors.tools[event];
tools = code->_co_monitoring->active_monitors.tools[event];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant