From: Tian Gao Date: Fri, 26 Apr 2024 16:01:44 +0000 (-0700) Subject: gh-117385: Remove unhooked events on sys.settrace (GH-117386) X-Git-Tag: v3.13.0b1~254 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0f998613324bcb6fa1cd9a3a2fc7e46f67358df7;p=thirdparty%2FPython%2Fcpython.git gh-117385: Remove unhooked events on sys.settrace (GH-117386) --- 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 000000000000..2e385df39383 --- /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 d7aae7d2343a..b5a174059318 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) {