Skip to content

Commit f7056ea

Browse files
committed
gh-91435: docs review responses
1 parent 67f69a2 commit f7056ea

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

Doc/library/warnings.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,18 @@ Available Context Managers
507507
protected. This argument exists primarily for testing the :mod:`warnings`
508508
module itself.
509509

510+
If the *action* argument is not None, the remaining arguments are passed
511+
to :func:`simplefilter` as if it were called immediately on entering the
512+
context.
513+
510514
.. note::
511515

512516
The :class:`catch_warnings` manager works by replacing and
513517
then later restoring the module's
514518
:func:`showwarning` function and internal list of filter
515519
specifications. This means the context manager is modifying
516520
global state and therefore is not thread-safe.
521+
522+
.. versionchanged:: 3.11
523+
524+
Added the *action*, *category*, *lineno*, and *append* parameters.

Doc/whatsnew/3.11.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,13 @@ venv
521521
Third party code that also creates new virtual environments should do the same.
522522
(Contributed by Miro Hrončok in :issue:`45413`.)
523523

524+
warnings
525+
--------
526+
527+
* :func:`warnings.catch_warnings` now accepts arguments for :func:`warnings.simplefilter`,
528+
providing a more concise way to locally ignore warnings or convert them to errors.
529+
(Contributed by Zac Hatfield-Dodds in :issue:`47074`.)
530+
524531
zipfile
525532
-------
526533

Lib/warnings.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,11 +433,8 @@ class catch_warnings(object):
433433
when testing the warnings module itself.
434434
435435
If the 'action' argument is not None, the remaining arguments are passed
436-
to warnings.simplefilter() as if it that call was the first line of the
437-
with-statement.
438-
439-
.. versionchanged:: 3.11
440-
Added the action, category, lineno, and append arguments.
436+
to warnings.simplefilter() as if it were called immediately on entering the
437+
context.
441438
"""
442439

443440
def __init__(self, *, record=False, module=None,

0 commit comments

Comments
 (0)