gh-146642: Clarify -W regex requires at least two characters#147969
Open
WYSIATI wants to merge 1 commit intopython:mainfrom
Open
gh-146642: Clarify -W regex requires at least two characters#147969WYSIATI wants to merge 1 commit intopython:mainfrom
WYSIATI wants to merge 1 commit intopython:mainfrom
Conversation
The documentation for the -W option's message and module fields states that a value starting and ending with a forward slash is treated as a regular expression. However, the implementation requires the value to be at least two characters long (so a bare "/" is treated as a literal string, not a regex). Update the docs in both cmdline.rst and warnings.rst to mention this requirement.
610565c to
7c61e57
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #146642.
The documentation for the
-Woption's message and module fields says that a value "starts and ends with a forward slash (/)" is treated as a regular expression. However, the implementation inLib/_py_warnings.py(_setoption(), lines 372 and 377) requireslen(value) >= 2, so a bare/is treated as a literal string, not a regex.This PR updates the docs in both
Doc/using/cmdline.rstandDoc/library/warnings.rstto mention the minimum length requirement, matching the actual behavior.Changes
Doc/using/cmdline.rst: Add "at least two characters long" qualifier for both message and module regex detectionDoc/library/warnings.rst: Same clarification for both message and module fields📚 Documentation preview 📚: https://cpython-previews--147969.org.readthedocs.build/