|
1 | | - |
2 | 1 | :mod:`warnings` --- Warning control |
3 | 2 | =================================== |
4 | 3 |
|
@@ -131,16 +130,16 @@ the disposition of the match. Each entry is a tuple of the form (*action*, |
131 | 130 | +---------------+----------------------------------------------+ |
132 | 131 |
|
133 | 132 | * *message* is a string containing a regular expression that the warning message |
134 | | - must match (the match is compiled to always be case-insensitive) |
| 133 | + must match (the match is compiled to always be case-insensitive). |
135 | 134 |
|
136 | 135 | * *category* is a class (a subclass of :exc:`Warning`) of which the warning |
137 | | - category must be a subclass in order to match |
| 136 | + category must be a subclass in order to match. |
138 | 137 |
|
139 | 138 | * *module* is a string containing a regular expression that the module name must |
140 | | - match (the match is compiled to be case-sensitive) |
| 139 | + match (the match is compiled to be case-sensitive). |
141 | 140 |
|
142 | 141 | * *lineno* is an integer that the line number where the warning occurred must |
143 | | - match, or ``0`` to match all line numbers |
| 142 | + match, or ``0`` to match all line numbers. |
144 | 143 |
|
145 | 144 | Since the :exc:`Warning` class is derived from the built-in :exc:`Exception` |
146 | 145 | class, to turn a warning into an error we simply raise ``category(message)``. |
@@ -285,29 +284,32 @@ Available Functions |
285 | 284 |
|
286 | 285 | .. function:: formatwarning(message, category, filename, lineno[, line]) |
287 | 286 |
|
288 | | - Format a warning the standard way. This returns a string which may contain |
289 | | - embedded newlines and ends in a newline. *line* is |
290 | | - a line of source code to be included in the warning message; if *line* is not supplied, |
291 | | - :func:`formatwarning` will try to read the line specified by *filename* and *lineno*. |
| 287 | + Format a warning the standard way. This returns a string which may contain |
| 288 | + embedded newlines and ends in a newline. *line* is a line of source code to |
| 289 | + be included in the warning message; if *line* is not supplied, |
| 290 | + :func:`formatwarning` will try to read the line specified by *filename* and |
| 291 | + *lineno*. |
292 | 292 |
|
293 | 293 |
|
294 | 294 | .. function:: filterwarnings(action[, message[, category[, module[, lineno[, append]]]]]) |
295 | 295 |
|
296 | | - Insert an entry into the list of warnings filters. The entry is inserted at the |
297 | | - front by default; if *append* is true, it is inserted at the end. This checks |
298 | | - the types of the arguments, compiles the message and module regular expressions, |
299 | | - and inserts them as a tuple in the list of warnings filters. Entries closer to |
| 296 | + Insert an entry into the list of :ref:`warnings filter specifications |
| 297 | + <warning-filter>`. The entry is inserted at the front by default; if |
| 298 | + *append* is true, it is inserted at the end. This checks the types of the |
| 299 | + arguments, compiles the *message* and *module* regular expressions, and |
| 300 | + inserts them as a tuple in the list of warnings filters. Entries closer to |
300 | 301 | the front of the list override entries later in the list, if both match a |
301 | 302 | particular warning. Omitted arguments default to a value that matches |
302 | 303 | everything. |
303 | 304 |
|
304 | 305 |
|
305 | 306 | .. function:: simplefilter(action[, category[, lineno[, append]]]) |
306 | 307 |
|
307 | | - Insert a simple entry into the list of warnings filters. The meaning of the |
308 | | - function parameters is as for :func:`filterwarnings`, but regular expressions |
309 | | - are not needed as the filter inserted always matches any message in any module |
310 | | - as long as the category and line number match. |
| 308 | + Insert a simple entry into the list of :ref:`warnings filter specifications |
| 309 | + <warning-filter>`. The meaning of the function parameters is as for |
| 310 | + :func:`filterwarnings`, but regular expressions are not needed as the filter |
| 311 | + inserted always matches any message in any module as long as the category and |
| 312 | + line number match. |
311 | 313 |
|
312 | 314 |
|
313 | 315 | .. function:: resetwarnings() |
|
0 commit comments