Mailing List Archive

gh-117385: Remove unhooked events on sys.settrace (GH-117386)
https://github.com/python/cpython/commit/0f998613324bcb6fa1cd9a3a2fc7e46f67358df7
commit: 0f998613324bcb6fa1cd9a3a2fc7e46f67358df7
branch: main
author: Tian Gao <gaogaotiantian@hotmail.com>
committer: markshannon <mark@hotpy.org>
date: 2024-04-26T17:01:44+01:00
summary:

gh-117385: Remove unhooked events on sys.settrace (GH-117386)

files:
A Misc/NEWS.d/next/Core and Builtins/2024-03-30-00-37-53.gh-issue-117385.h0OJti.rst
M Python/legacy_tracing.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-03-30-00-37-53.gh-issue-117385.h0OJti.rst b/Misc/NEWS.d/next/Core and Builtins/2024-03-30-00-37-53.gh-issue-117385.h0OJti.rst
new file mode 100644
index 00000000000000..2e385df3938347
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2024-03-30-00-37-53.gh-issue-117385.h0OJti.rst
@@ -0,0 +1 @@
+Remove unhandled ``PY_MONITORING_EVENT_BRANCH`` and ``PY_MONITORING_EVENT_EXCEPTION_HANDLED`` events from :func:`sys.settrace`.
diff --git a/Python/legacy_tracing.c b/Python/legacy_tracing.c
index d7aae7d2343ac2..b5a17405931825 100644
--- a/Python/legacy_tracing.c
+++ b/Python/legacy_tracing.c
@@ -599,10 +599,9 @@ _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg)
(1 << PY_MONITORING_EVENT_PY_START) | (1 << PY_MONITORING_EVENT_PY_RESUME) |
(1 << PY_MONITORING_EVENT_PY_RETURN) | (1 << PY_MONITORING_EVENT_PY_YIELD) |
(1 << PY_MONITORING_EVENT_RAISE) | (1 << PY_MONITORING_EVENT_LINE) |
- (1 << PY_MONITORING_EVENT_JUMP) | (1 << PY_MONITORING_EVENT_BRANCH) |
+ (1 << PY_MONITORING_EVENT_JUMP) |
(1 << PY_MONITORING_EVENT_PY_UNWIND) | (1 << PY_MONITORING_EVENT_PY_THROW) |
- (1 << PY_MONITORING_EVENT_STOP_ITERATION) |
- (1 << PY_MONITORING_EVENT_EXCEPTION_HANDLED);
+ (1 << PY_MONITORING_EVENT_STOP_ITERATION);

PyFrameObject* frame = PyEval_GetFrame();
if (frame->f_trace_opcodes) {

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-leave@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: list-python-checkins@lists.gossamer-threads.com