Skip to content

Commit

Permalink
gh-91435: docs review responses
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Apr 19, 2022
1 parent 67f69a2 commit f7056ea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
8 changes: 8 additions & 0 deletions Doc/library/warnings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,18 @@ 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
then later restoring the module's
: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.
7 changes: 7 additions & 0 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,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
-------

Expand Down
7 changes: 2 additions & 5 deletions Lib/warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,8 @@ class catch_warnings(object):
when testing the warnings module itself.
If the 'action' argument is not None, the remaining arguments are passed
to warnings.simplefilter() as if it that call was the first line of the
with-statement.
.. versionchanged:: 3.11
Added the action, category, lineno, and append arguments.
to warnings.simplefilter() as if it were called immediately on entering the
context.
"""

def __init__(self, *, record=False, module=None,
Expand Down

0 comments on commit f7056ea

Please sign in to comment.