bpo-42272: fix misleading warning filter message/module docs (GH-23172) · python/cpython@cc31cfc · GitHub
Skip to content

Commit cc31cfc

Browse files
bpo-42272: fix misleading warning filter message/module docs (GH-23172)
* bpo-42272: improve message/module warning filter docs "The Warnings Filter" section of the warnings module documentation describes the message and module filters as "a string containing a regular expression". While that is true when they are arguments to the filterwarnings function, it is not true when they appear in -W or $PYTHONWARNINGS where they are matched literally (after stripping any starting/ending whitespace). Update the documentation to note when they are matched literally. Also clarify that module matches the "fully-qualified module name", rather than "module name" which is ambiguous. skip news (since this is a doc fix) Signed-off-by: Kevin Locke <kevin@kevinlocke.name> * bpo-42272: remove bad submodule warning filter doc The `error:::mymodule[.*]` example in the "Describing Warning Filters" section of the warnings module documentation does not behave as the comment describes. Since the module portion of the filter string is interpreted literally, it would match a module with a fully-qualified name that is literally `mymodule[.*]`. Unfortunately, there is not a way to match '"module" and any subpackages of "mymodule"' as documented, since the module part of a filter string is matched literally. Instead, update the filter and comment to match only "mymodule". skip news (since this is a doc fix) Signed-off-by: Kevin Locke <kevin@kevinlocke.name> * bpo-42272: add warning filter doc changes to NEWS Signed-off-by: Kevin Locke <kevin@kevinlocke.name> (cherry picked from commit 8136606) Co-authored-by: Kevin Locke <kevin@kevinlocke.name>
1 parent 624fc61 commit cc31cfc

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

Doc/library/warnings.rst

Lines changed: 10 additions & 6 deletions
Lines changed: 3 additions & 0 deletions

0 commit comments

Comments
 (0)