Skip to content

Commit 0dcae29

Browse files
committed
Clarify some details regarding sys.monitoring
1 parent 9ad0c7b commit 0dcae29

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

Doc/library/sys.monitoring.rst

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ events, use the expression ``PY_RETURN | PY_START``.
171171
if get_events(DEBUGGER_ID) == NO_EVENTS:
172172
...
173173

174-
Events are divided into three groups:
174+
Setting this event deactivates all events.
175+
176+
Events can be divided into groups:
175177

176178
.. _monitoring-event-local:
177179

@@ -292,9 +294,10 @@ in Python (see :ref:`c-api-monitoring`).
292294
Activates all the local events for *code* which are set in *event_set*.
293295
Raises a :exc:`ValueError` if *tool_id* is not in use.
294296

295-
Local events add to global events, but do not mask them.
296-
In other words, all global events will trigger for a code object,
297-
regardless of the local events.
297+
Local events add to global events. In other words, all global events
298+
will trigger for a code object, regardless of the local events. Events
299+
will also only trigger once regardless of whether the same event is
300+
registered both globally and locally for a code object.
298301

299302

300303
Disabling events
@@ -325,8 +328,6 @@ except for a few breakpoints.
325328
Registering callback functions
326329
------------------------------
327330

328-
To register a callable for events call
329-
330331
.. function:: register_callback(tool_id: int, event: int, func: Callable | None, /) -> Callable | None
331332

332333
Registers the callable *func* for the *event* with the given *tool_id*
@@ -367,8 +368,15 @@ Different events will provide the callback function with different arguments, as
367368

368369
func(code: CodeType, instruction_offset: int, callable: object, arg0: object | MISSING) -> DISABLE | Any
369370

371+
*code* represents the code object where the call is being made, while
372+
*callable* is the object that is about to be called (and thus
373+
triggered the event).
370374
If there are no arguments, *arg0* is set to :data:`sys.monitoring.MISSING`.
371375

376+
For instance methods, *callable* will be the function object as found on the
377+
class with *arg0* set to the instance (i.e. the ``self`` argument to the
378+
method).
379+
372380
* :monitoring-event:`RAISE`, :monitoring-event:`RERAISE`, :monitoring-event:`EXCEPTION_HANDLED`,
373381
:monitoring-event:`PY_UNWIND`, :monitoring-event:`PY_THROW` and :monitoring-event:`STOP_ITERATION`::
374382

0 commit comments

Comments
 (0)