From 3beae8be539a98b2bcd9f36fde33475720261ed2 Mon Sep 17 00:00:00 2001 From: Kanishk Pachauri Date: Sun, 2 Mar 2025 22:58:39 +0530 Subject: [PATCH 1/2] gh-129846: docs(warnings): clarify suppression of warning output in `catch_warnings` --- Doc/library/warnings.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/warnings.rst b/Doc/library/warnings.rst index 0c7e8543f331db..61cf7cb7b35b2d 100644 --- a/Doc/library/warnings.rst +++ b/Doc/library/warnings.rst @@ -597,7 +597,7 @@ Available Context Managers If the *record* argument is :const:`False` (the default) the context manager returns :class:`None` on entry. If *record* is :const:`True`, a list is returned that is progressively populated with objects as seen by a custom - :func:`showwarning` function (which also suppresses output to ``sys.stdout``). + :func:`showwarning` function (which also suppresses output to ``sys.stderr`` and other streams). Each object in the list has attributes with the same names as the arguments to :func:`showwarning`. From 1d8e23fb27d894e917e794166c3b6d6e354f4be4 Mon Sep 17 00:00:00 2001 From: Kanishk Pachauri Date: Tue, 4 Mar 2025 00:00:55 +0530 Subject: [PATCH 2/2] Update Doc/library/warnings.rst Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Doc/library/warnings.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/library/warnings.rst b/Doc/library/warnings.rst index 61cf7cb7b35b2d..c101c56f72cd97 100644 --- a/Doc/library/warnings.rst +++ b/Doc/library/warnings.rst @@ -595,8 +595,9 @@ Available Context Managers A context manager that copies and, upon exit, restores the warnings filter and the :func:`showwarning` function. If the *record* argument is :const:`False` (the default) the context manager - returns :class:`None` on entry. If *record* is :const:`True`, a list is - returned that is progressively populated with objects as seen by a custom + returns :class:`None` on entry. If *record* is :const:`True`, the default + warning stream is intercepted and a list is returned that is progressively + populated with objects as seen by a custom :func:`showwarning` function (which also suppresses output to ``sys.stderr`` and other streams). Each object in the list has attributes with the same names as the arguments to :func:`showwarning`.