From f330dafa309133374023490c284488376a6dc051 Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Tue, 24 Oct 2023 14:52:44 -0700 Subject: [PATCH 1/2] Add restart_events() and positional arg semantics --- Doc/library/sys.monitoring.rst | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Doc/library/sys.monitoring.rst b/Doc/library/sys.monitoring.rst index c2168cd9f06b08..6ef8278250dfce 100644 --- a/Doc/library/sys.monitoring.rst +++ b/Doc/library/sys.monitoring.rst @@ -44,17 +44,17 @@ Identifiers are integers in the range 0 to 5 inclusive. Registering and using tools ''''''''''''''''''''''''''' -.. function:: use_tool_id(tool_id: int, name: str) -> None +.. function:: use_tool_id(tool_id: int, name: str, /) -> None Must be called before *tool_id* can be used. *tool_id* must be in the range 0 to 5 inclusive. Raises a :exc:`ValueError` if *tool_id* is in use. -.. function:: free_tool_id(tool_id: int) -> None +.. function:: free_tool_id(tool_id: int, /) -> None Should be called once a tool no longer requires *tool_id*. -.. function:: get_tool(tool_id: int) -> str | None +.. function:: get_tool(tool_id: int, /) -> str | None Returns the name of the tool if *tool_id* is in use, otherwise it returns ``None``. @@ -237,11 +237,11 @@ Setting events globally Events can be controlled globally by modifying the set of events being monitored. -.. function:: get_events(tool_id: int) -> int +.. function:: get_events(tool_id: int, /) -> int Returns the ``int`` representing all the active events. -.. function:: set_events(tool_id: int, event_set: int) +.. function:: set_events(tool_id: int, event_set: int, /) Activates all events which are set in *event_set*. Raises a :exc:`ValueError` if *tool_id* is not in use. @@ -253,11 +253,11 @@ Per code object events Events can also be controlled on a per code object basis. -.. function:: get_local_events(tool_id: int, code: CodeType) -> int +.. function:: get_local_events(tool_id: int, code: CodeType, /) -> int Returns all the local events for *code* -.. function:: set_local_events(tool_id: int, code: CodeType, event_set: int) +.. function:: set_local_events(tool_id: int, code: CodeType, event_set: int, /) Activates all the local events for *code* which are set in *event_set*. Raises a :exc:`ValueError` if *tool_id* is not in use. @@ -284,6 +284,11 @@ performance monitoring. For example, a program can be run under a debugger with no overhead if the debugger disables all monitoring except for a few breakpoints. +.. function:: restart_events() + + Enable all the events that were disabled by :data:`sys.monitoring.DISABLE` + for all tools. + .. _callbacks: @@ -292,7 +297,7 @@ Registering callback functions To register a callable for events call -.. function:: register_callback(tool_id: int, event: int, func: Callable | None) -> Callable | None +.. function:: register_callback(tool_id: int, event: int, func: Callable | None, /) -> Callable | None Registers the callable *func* for the *event* with the given *tool_id* From 107d32147bd473bf8bc21c7d2ba10aaf297a95c3 Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Wed, 25 Oct 2023 10:52:42 -0700 Subject: [PATCH 2/2] Explicitly add return type None. Co-authored-by: Alex Waygood --- Doc/library/sys.monitoring.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/sys.monitoring.rst b/Doc/library/sys.monitoring.rst index 6ef8278250dfce..f2fe3d76248c2c 100644 --- a/Doc/library/sys.monitoring.rst +++ b/Doc/library/sys.monitoring.rst @@ -241,7 +241,7 @@ Events can be controlled globally by modifying the set of events being monitored Returns the ``int`` representing all the active events. -.. function:: set_events(tool_id: int, event_set: int, /) +.. function:: set_events(tool_id: int, event_set: int, /) -> None Activates all events which are set in *event_set*. Raises a :exc:`ValueError` if *tool_id* is not in use. @@ -257,7 +257,7 @@ Events can also be controlled on a per code object basis. Returns all the local events for *code* -.. function:: set_local_events(tool_id: int, code: CodeType, event_set: int, /) +.. function:: set_local_events(tool_id: int, code: CodeType, event_set: int, /) -> None Activates all the local events for *code* which are set in *event_set*. Raises a :exc:`ValueError` if *tool_id* is not in use. @@ -284,7 +284,7 @@ performance monitoring. For example, a program can be run under a debugger with no overhead if the debugger disables all monitoring except for a few breakpoints. -.. function:: restart_events() +.. function:: restart_events() -> None Enable all the events that were disabled by :data:`sys.monitoring.DISABLE` for all tools.