summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/warnings.rst10
-rw-r--r--Doc/whatsnew/3.11.rst7
2 files changed, 16 insertions, 1 deletions
diff --git a/Doc/library/warnings.rst b/Doc/library/warnings.rst
index 289b282..f7a1f70 100644
--- a/Doc/library/warnings.rst
+++ b/Doc/library/warnings.rst
@@ -491,7 +491,7 @@ Available Functions
Available Context Managers
--------------------------
-.. class:: catch_warnings(*, record=False, module=None)
+.. class:: catch_warnings(*, record=False, module=None, action=None, category=Warning, lineno=0, append=False)
A context manager that copies and, upon exit, restores the warnings filter
and the :func:`showwarning` function.
@@ -507,6 +507,10 @@ Available Context Managers
protected. This argument exists primarily for testing the :mod:`warnings`
module itself.
+ If the *action* argument is not ``None``, the remaining arguments are
+ passed to :func:`simplefilter` as if it were called immediately on
+ entering the context.
+
.. note::
The :class:`catch_warnings` manager works by replacing and
@@ -514,3 +518,7 @@ Available Context Managers
:func:`showwarning` function and internal list of filter
specifications. This means the context manager is modifying
global state and therefore is not thread-safe.
+
+ .. versionchanged:: 3.11
+
+ Added the *action*, *category*, *lineno*, and *append* parameters.
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index 3474251..43d8e6b 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -529,6 +529,13 @@ venv
Third party code that also creates new virtual environments should do the same.
(Contributed by Miro HronĨok in :issue:`45413`.)
+warnings
+--------
+
+* :func:`warnings.catch_warnings` now accepts arguments for :func:`warnings.simplefilter`,
+ providing a more concise way to locally ignore warnings or convert them to errors.
+ (Contributed by Zac Hatfield-Dodds in :issue:`47074`.)
+
zipfile
-------