@@ -180,8 +180,8 @@ Local events
180180''''''''''''
181181
182182Local events are associated with normal execution of the program and happen
183- at clearly defined locations. All local events can be disabled.
184- The local events are:
183+ at clearly defined locations. All local events can be disabled
184+ per location. The local events are:
185185
186186* :monitoring-event: `PY_START `
187187* :monitoring-event: `PY_RESUME `
@@ -205,6 +205,8 @@ Using :monitoring-event:`BRANCH_LEFT` and :monitoring-event:`BRANCH_RIGHT`
205205events will give much better performance as they can be disabled
206206independently.
207207
208+ .. _monitoring-ancillary-events :
209+
208210Ancillary events
209211''''''''''''''''
210212
@@ -226,14 +228,20 @@ Other events
226228''''''''''''
227229
228230Other events are not necessarily tied to a specific location in the
229- program and cannot be individually disabled via :data: ` DISABLE ` .
231+ program and cannot be individually disabled per location .
230232
231233The other events that can be monitored are:
232234
233235* :monitoring-event: `PY_THROW `
234236* :monitoring-event: `PY_UNWIND `
235237* :monitoring-event: `RAISE `
236238* :monitoring-event: `EXCEPTION_HANDLED `
239+ * :monitoring-event: `RERAISE `
240+
241+ .. versionchanged :: 3.15
242+ Other events can now be turned on and disabled on a per code object
243+ basis. Returning :data: `DISABLE ` from a callback disables the event
244+ for the entire code object (for the current tool).
237245
238246
239247The STOP_ITERATION event
@@ -247,8 +255,7 @@ raise an exception unless it would be visible to other code.
247255
248256To allow tools to monitor for real exceptions without slowing down generators
249257and coroutines, the :monitoring-event: `STOP_ITERATION ` event is provided.
250- :monitoring-event: `STOP_ITERATION ` can be locally disabled, unlike
251- :monitoring-event: `RAISE `.
258+ :monitoring-event: `STOP_ITERATION ` can be locally disabled.
252259
253260Note that the :monitoring-event: `STOP_ITERATION ` event and the
254261:monitoring-event: `RAISE ` event for a :exc: `StopIteration ` exception are
@@ -314,15 +321,14 @@ location by returning :data:`sys.monitoring.DISABLE` from a callback function.
314321This does not change which events are set, or any other code locations for the
315322same event.
316323
317- Disabling events for specific locations is very important for high
318- performance monitoring. For example, a program can be run under a
319- debugger with no overhead if the debugger disables all monitoring
320- except for a few breakpoints .
324+ :ref: ` Other events < monitoring-event-global >` can be disabled on a per code
325+ object basis by returning :data: ` sys.monitoring.DISABLE ` from a callback
326+ function. This disables the event for the entire code object (for the current
327+ tool) .
321328
322- If :data: `DISABLE ` is returned by a callback for a
323- :ref: `global event <monitoring-event-global >`, :exc: `ValueError ` will be raised
324- by the interpreter in a non-specific location (that is, no traceback will be
325- provided).
329+ Disabling events for specific locations is very important for high performance
330+ monitoring. For example, a program can be run under a debugger with no overhead
331+ if the debugger disables all monitoring except for a few breakpoints.
326332
327333.. function :: restart_events() -> None
328334
0 commit comments