Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Side by Side Diff: Doc/library/warnings.rst

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/library/urllib.request.rst ('k') | Doc/library/xdrlib.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`warnings` --- Warning control 1 :mod:`warnings` --- Warning control
2 =================================== 2 ===================================
3 3
4 .. index:: single: warnings 4 .. index:: single: warnings
5 5
6 .. module:: warnings 6 .. module:: warnings
7 :synopsis: Issue warning messages and control their disposition. 7 :synopsis: Issue warning messages and control their disposition.
8 8
9 **Source code:** :source:`Lib/warnings.py` 9 **Source code:** :source:`Lib/warnings.py`
10 10
(...skipping 21 matching lines...) Expand all
32 32
33 The determination whether to issue a warning message is controlled by the 33 The determination whether to issue a warning message is controlled by the
34 warning filter, which is a sequence of matching rules and actions. Rules can be 34 warning filter, which is a sequence of matching rules and actions. Rules can be
35 added to the filter by calling :func:`filterwarnings` and reset to its default 35 added to the filter by calling :func:`filterwarnings` and reset to its default
36 state by calling :func:`resetwarnings`. 36 state by calling :func:`resetwarnings`.
37 37
38 The printing of warning messages is done by calling :func:`showwarning`, which 38 The printing of warning messages is done by calling :func:`showwarning`, which
39 may be overridden; the default implementation of this function formats the 39 may be overridden; the default implementation of this function formats the
40 message by calling :func:`formatwarning`, which is also available for use by 40 message by calling :func:`formatwarning`, which is also available for use by
41 custom implementations. 41 custom implementations.
42
43 .. seealso::
44 :func:`logging.captureWarnings` allows you to handle all warnings with
45 the standard logging infrastructure.
46 42
47 43
48 .. _warning-categories: 44 .. _warning-categories:
49 45
50 Warning Categories 46 Warning Categories
51 ------------------ 47 ------------------
52 48
53 There are a number of built-in exceptions that represent warning categories. 49 There are a number of built-in exceptions that represent warning categories.
54 This categorization is useful to be able to filter out groups of warnings. The 50 This categorization is useful to be able to filter out groups of warnings. The
55 following warnings category classes are currently defined: 51 following warnings category classes are currently defined:
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 for which the warning is issued. (This argument is used to support displayin g 328 for which the warning is issued. (This argument is used to support displayin g
333 source for modules found in zipfiles or other non-filesystem import 329 source for modules found in zipfiles or other non-filesystem import
334 sources). 330 sources).
335 331
336 332
337 .. function:: showwarning(message, category, filename, lineno, file=None, line=N one) 333 .. function:: showwarning(message, category, filename, lineno, file=None, line=N one)
338 334
339 Write a warning to a file. The default implementation calls 335 Write a warning to a file. The default implementation calls
340 ``formatwarning(message, category, filename, lineno, line)`` and writes the 336 ``formatwarning(message, category, filename, lineno, line)`` and writes the
341 resulting string to *file*, which defaults to ``sys.stderr``. You may replac e 337 resulting string to *file*, which defaults to ``sys.stderr``. You may replac e
342 this function with any callable by assigning to ``warnings.showwarning``. 338 this function with an alternative implementation by assigning to
339 ``warnings.showwarning``.
343 *line* is a line of source code to be included in the warning 340 *line* is a line of source code to be included in the warning
344 message; if *line* is not supplied, :func:`showwarning` will 341 message; if *line* is not supplied, :func:`showwarning` will
345 try to read the line specified by *filename* and *lineno*. 342 try to read the line specified by *filename* and *lineno*.
346 343
347 344
348 .. function:: formatwarning(message, category, filename, lineno, line=None) 345 .. function:: formatwarning(message, category, filename, lineno, line=None)
349 346
350 Format a warning the standard way. This returns a string which may contain 347 Format a warning the standard way. This returns a string which may contain
351 embedded newlines and ends in a newline. *line* is a line of source code to 348 embedded newlines and ends in a newline. *line* is a line of source code to
352 be included in the warning message; if *line* is not supplied, 349 be included in the warning message; if *line* is not supplied,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 protected. This argument exists primarily for testing the :mod:`warnings` 398 protected. This argument exists primarily for testing the :mod:`warnings`
402 module itself. 399 module itself.
403 400
404 .. note:: 401 .. note::
405 402
406 The :class:`catch_warnings` manager works by replacing and 403 The :class:`catch_warnings` manager works by replacing and
407 then later restoring the module's 404 then later restoring the module's
408 :func:`showwarning` function and internal list of filter 405 :func:`showwarning` function and internal list of filter
409 specifications. This means the context manager is modifying 406 specifications. This means the context manager is modifying
410 global state and therefore is not thread-safe. 407 global state and therefore is not thread-safe.
OLDNEW
« no previous file with comments | « Doc/library/urllib.request.rst ('k') | Doc/library/xdrlib.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+