mirror of
https://github.com/python/cpython.git
synced 2025-11-08 13:42:22 +00:00
Add documentation about the default warnings filters.
This commit is contained in:
parent
08be72d0aa
commit
2062937aff
1 changed files with 21 additions and 3 deletions
|
|
@ -94,9 +94,6 @@ User code can define additional warning categories by subclassing one of the
|
||||||
standard warning categories. A warning category must always be a subclass of
|
standard warning categories. A warning category must always be a subclass of
|
||||||
the :exc:`Warning` class.
|
the :exc:`Warning` class.
|
||||||
|
|
||||||
.. versionchanged:: 3.2
|
|
||||||
:exc:`DeprecationWarning` is ignored by default.
|
|
||||||
|
|
||||||
|
|
||||||
.. _warning-filter:
|
.. _warning-filter:
|
||||||
|
|
||||||
|
|
@ -157,6 +154,27 @@ interpreter command line. The interpreter saves the arguments for all
|
||||||
are ignored, after printing a message to ``sys.stderr``).
|
are ignored, after printing a message to ``sys.stderr``).
|
||||||
|
|
||||||
|
|
||||||
|
Default Warning Filters
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
By default, Python installs several warning filters, which can be overridden by
|
||||||
|
the command-line options passed to :option:`-W` and calls to
|
||||||
|
:func:`filterwarnings`.
|
||||||
|
|
||||||
|
* :exc:`DeprecationWarning` and :exc:`PendingDeprecationWarning`, and
|
||||||
|
:exc:`ImportWarning` are ignored.
|
||||||
|
|
||||||
|
* :exc:`BytesWarning` is ignored unless the :option:`-b` option is given once or
|
||||||
|
twice; in this case this warning is either printed (``-b``) or turned into an
|
||||||
|
exception (``-bb`).
|
||||||
|
|
||||||
|
* :exc:`ResourceWarning` is ignored unless Python was built in debug mode.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.2
|
||||||
|
:exc:`DeprecationWarning` is now ignored by default in addition to
|
||||||
|
:exc:`PendingDeprecationWarning`.
|
||||||
|
|
||||||
|
|
||||||
.. _warning-suppress:
|
.. _warning-suppress:
|
||||||
|
|
||||||
Temporarily Suppressing Warnings
|
Temporarily Suppressing Warnings
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue