GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-142186: all-local PEP-669 events by P403n1x87 · Pull Request #146182 · python/cpython

Conversation

@P403n1x87

@P403n1x87 P403n1x87 commented Mar 19, 2026 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

  • Issue: Make the PY_UNWIND monitoring event local #142186

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
P403n1x87 added 4 commits March 19, 2026 12:03
@P403n1x87
Make PY_UNWIND available as a local event
07a26bd
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.
@P403n1x87
break local == instrumented assumption
1a3e828
@P403n1x87
add DISABLE support for PY_UNWIND
6d743f9
@P403n1x87
Make all PEP-669 events local
b5758b3
We make all the events of the low-impact monitoring API local,
shifting the distinction to whether they are instrumented or
non-instrumented.
@bedevere-app bedevere-app Bot mentioned this pull request Mar 19, 2026
Make the PY_UNWIND monitoring event local #142186
Closed
@P403n1x87
rename PY_MONITORING_IS_LOCAL_EVENT -> PY_MONITORING_IS_UNGROUPED_EVENT
3b8e1d5
@P403n1x87
P403n1x87 force-pushed the gh-142186-pep-669-all-local-events branch from d02dc43 to 3b8e1d5 Compare March 19, 2026 18:18
P403n1x87
P403n1x87 commented Mar 19, 2026
View reviewed changes
Comment thread Python/instrumentation.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

P403n1x87 added 2 commits March 20, 2026 12:09
@P403n1x87
fix get_tools_for_instruction
8fb54fa
@P403n1x87
add blurb note
958595a
@P403n1x87
P403n1x87 marked this pull request as ready for review March 23, 2026 11:36
@P403n1x87
P403n1x87 requested a review from markshannon as a code owner March 23, 2026 11:36
@bedevere-app bedevere-app Bot added the awaiting review label Mar 23, 2026
@P403n1x87

P403n1x87 commented Apr 6, 2026

Copy link
Copy Markdown
Contributor Author

@markshannon apologies for pinging you again, I appreciate you might be busy with other work. I would love for this to land in main before the first beta in May if possible 🙏

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@P403n1x87 P403n1x87 mentioned this pull request Apr 16, 2026
chore(tracing): [2/n] support Python 3.15 coroutine and generator wrapping DataDog/dd-trace-py#17531
Closed
@markshannon

markshannon commented Apr 17, 2026

Copy link
Copy Markdown
Member

Overall, this looks good in terms of semantics and capabilities.

I do have a problem with the naming, though. If we make all events "local", that does make the term "local" rather meaningless and terminology you use such as "instrumented local events" and "non-instrumented local events" is a bit opaque.
No user should really have to care about whether the implementation uses instrumentation or not.

Also, there is still a clear distinction between the events that can be precisely disabled and those that can only be disabled per code object.

So, with that in mind, I think we should still keep the terms "global" and "local" for the events they apply to now, and merely frame the change as "global events can now be turned on and disable on a per-code object basis".

In the docs, change "All local events can be disabled" to "All local events can be disabled per location"

It is unfortunate the functions get_local_events and set_local_events are so named as that does confuse the issue.

Sorry for taking so long to get back to this. It will get into 3.15

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@P403n1x87
keep local vs other separation
7761135
@P403n1x87

P403n1x87 commented Apr 18, 2026

Copy link
Copy Markdown
Contributor Author

@markshannon many thanks for your review.

No user should really have to care about whether the implementation uses instrumentation or not.

I totally agree with this sentiment, however a feature like the low-impact monitoring API sits quite close to the "stripped wires" that it becomes tricky to avoid that. However

there is still a clear distinction between the events that can be precisely disabled and those that can only be disabled per code object.

so as requested I have made some changes to the wording in the documentation and comments to try and capture this instead.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@P403n1x87
Merge branch 'main' into pythongh-142186-pep-669-all-local-events
5545d46
@markshannon

markshannon commented Apr 21, 2026

Copy link
Copy Markdown
Member

This turned out to be a nice improvement.

The code looks good.
Could you add a section to the "what's new" explaining the new behavior? (and I think it should be good to merge)

Thanks for doing this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@P403n1x87
add whatsnew entry
c6d23e9
@P403n1x87
P403n1x87 requested a review from AA-Turner as a code owner April 21, 2026 17:29
@P403n1x87

P403n1x87 commented Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

@markshannon that's the "what's new" entry added. Thanks for your feedback and help with this 🙇

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon

markshannon commented Apr 22, 2026

Copy link
Copy Markdown
Member

Excellent. Thanks once again

P403n1x87 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon
markshannon merged commit 858e69e into python:main Apr 22, 2026
59 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting review label Apr 22, 2026
@P403n1x87
P403n1x87 deleted the gh-142186-pep-669-all-local-events branch April 22, 2026 08:57
@da-woods da-woods mentioned this pull request Apr 23, 2026
sys_monitoring test failure cython/cython#7633
Closed
@scoder scoder mentioned this pull request Apr 24, 2026
gh-142186: Revert the unintended value change in the PY_MONITORING_EVENT_* values from gh-146182 #148955
Merged
scoder added a commit that referenced this pull request Apr 25, 2026
@scoder
gh-142186: Revert the unintended value change in the `PY_MONITORING_E…
db0ee44
…VENT_*` values from gh-146182 (gh-148955)

#146182 left an unintended change in the `PY_MONITORING_*` macro values. This change reverts that part to avoid a user visible impact.
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@P403n1x87 @ljfp
pythongh-142186: Allow all PEP-669 events to be per-code object and d…
fd88da1
…isableable (pythonGH-146182)

* 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.

* Allow `PY_UNWIND`  to be `DISABLE`d; disabling it disables the event for the whole code object.

* Do the above for `PY_THROW`, `RAISE`, `EXCEPTION_HANDLED`, and `RERAISE` events.
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@scoder @ljfp
pythongh-142186: Revert the unintended value change in the `PY_MONITO…
3d4f054
…RING_EVENT_*` values from pythongh-146182 (pythongh-148955)

python#146182 left an unintended change in the `PY_MONITORING_*` macro values. This change reverts that part to avoid a user visible impact.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@P403n1x87 @markshannon
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.