Skip to content

gh-146642: Clarify -W regex requires at least two characters#147969

Open
WYSIATI wants to merge 1 commit intopython:mainfrom
WYSIATI:fix-w-regex-docs-146642
Open

gh-146642: Clarify -W regex requires at least two characters#147969
WYSIATI wants to merge 1 commit intopython:mainfrom
WYSIATI:fix-w-regex-docs-146642

Conversation

@WYSIATI
Copy link
Copy Markdown

@WYSIATI WYSIATI commented Apr 1, 2026

Closes #146642.

The documentation for the -W option'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 in Lib/_py_warnings.py (_setoption(), lines 372 and 377) requires len(value) >= 2, so a bare / is treated as a literal string, not a regex.

This PR updates the docs in both Doc/using/cmdline.rst and Doc/library/warnings.rst to 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 detection
  • Doc/library/warnings.rst: Same clarification for both message and module fields

📚 Documentation preview 📚: https://cpython-previews--147969.org.readthedocs.build/

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot bot commented Apr 1, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

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.
@WYSIATI WYSIATI force-pushed the fix-w-regex-docs-146642 branch from 610565c to 7c61e57 Compare April 1, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Documentation for new -W regex support fails to mention length requirement

1 participant