From d5ad142abb8d3adcdea55fa2ea2c81a2fb64dc9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Mon, 14 Sep 2026 12:51:59 +0200 Subject: [PATCH] gh-116750: Document 3.14 changes around sys.monitoring.clear_tool_id (GH-156706) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gh-116750: Document versionadded/versionchanged for sys.monitoring tool_id functions clear_tool_id() was added in 3.14 but lacked a versionadded note, and free_tool_id()'s behavior change (now calling clear_tool_id() before releasing the tool_id, rather than leaving events/callbacks registered) was undocumented. Also add a What's New in 3.14 entry for both. (cherry picked from commit f815f740381dcf797d8aa67b9a0eabf4869bc790) Co-authored-by: Christian Neumüller Co-authored-by: Ned Batchelder --- Doc/library/sys.monitoring.rst | 7 +++++++ Doc/whatsnew/3.14.rst | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/Doc/library/sys.monitoring.rst b/Doc/library/sys.monitoring.rst index 16e6b1d6dc786b0..32423d98e671df4 100644 --- a/Doc/library/sys.monitoring.rst +++ b/Doc/library/sys.monitoring.rst @@ -54,11 +54,18 @@ Registering and using tools Unregister all events and callback functions associated with *tool_id*. + .. versionadded:: 3.14 + .. function:: free_tool_id(tool_id: int, /) -> None Should be called once a tool no longer requires *tool_id*. Will call :func:`clear_tool_id` before releasing *tool_id*. + .. versionchanged:: 3.14 + Now calls :func:`clear_tool_id` before releasing *tool_id*. + Previously, it would not disable global or local events associated + with *tool_id*, nor unregister any callback functions. + .. function:: get_tool(tool_id: int, /) -> str | None Returns the name of the tool if *tool_id* is in use, diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index ebeaf8fc1fb491f..db5ed81df1e07f2 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -1907,6 +1907,12 @@ sys.monitoring These replace and deprecate the :monitoring-event:`!BRANCH` event. (Contributed by Mark Shannon in :gh:`122548`.) +* Add :func:`sys.monitoring.clear_tool_id` to unregister all events and + callback functions associated with a tool identifier. + :func:`sys.monitoring.free_tool_id` now calls it before releasing the + tool identifier, instead of leaving its events and callbacks registered. + (Contributed by Tian Gao in :gh:`116750`.) + sysconfig ---------