]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-142186: Allow all PEP-669 events to be per-code object and disableable (GH-146182)
authorGabriele N. Tornetta <P403n1x87@users.noreply.github.com>
Wed, 22 Apr 2026 08:08:23 +0000 (09:08 +0100)
committerGitHub <noreply@github.com>
Wed, 22 Apr 2026 08:08:23 +0000 (09:08 +0100)
commit858e69eab0949852cc41733e8465250fc80d0b66
tree0d420791869e5efd8ef34a8f8e413a1ca999bf03
parent09233bd19879284395aff97d7357b693893e6dd7
gh-142186: Allow all PEP-669 events to be per-code object and disableable  (GH-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.
Doc/library/sys.monitoring.rst
Doc/whatsnew/3.15.rst
Include/cpython/monitoring.h
Include/internal/pycore_ceval.h
Include/internal/pycore_instruments.h
Lib/test/test_monitoring.py
Misc/NEWS.d/next/Core_and_Builtins/2026-03-23-11-34-37.gh-issue-142186.v8Yp3W.rst [new file with mode: 0644]
Objects/genobject.c
Python/ceval.c
Python/ceval.h
Python/instrumentation.c