gh-142186: all-local PEP-669 events#146182
Draft
P403n1x87 wants to merge 5 commits intopython:mainfrom
Draft
Conversation
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.
d02dc43 to
3b8e1d5
Compare
P403n1x87
commented
Mar 19, 2026
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]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
DISABLEsentinel value differs. For instrumented events,DISABLEwill remove the instrumentation at the specific code location where the value was returned. For non-instrumented events,DISABLEwill simply disable the event for the whole code object.PY_UNWINDmonitoring event local #142186📚 Documentation preview 📚: https://cpython-previews--146182.org.readthedocs.build/