Skip to content

Commit d69bf9b

Browse files
author
Chester Li
committed
Clarify single / edge case instead of length requirement
Replace "at least two characters long" with a parenthetical note that a single / on its own is treated as a literal string.
1 parent 98becb1 commit d69bf9b

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

Doc/library/warnings.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ the disposition of the match. Each entry is a tuple of the form (*action*,
159159

160160
* *message* is a string containing a regular expression that the start of
161161
the warning message must match, case-insensitively. In :option:`-W` and
162-
:envvar:`PYTHONWARNINGS`, if *message* is at least two characters long and
163-
starts and ends with a forward slash (``/``), it specifies a regular
164-
expression as above; otherwise it is a literal string that the start of the
162+
:envvar:`PYTHONWARNINGS`, if *message* starts and ends with a forward
163+
slash (``/``), it specifies a regular expression as above (a single ``/``
164+
on its own is treated as a literal string); otherwise it is a literal
165+
string that the start of the
165166
warning message must match (case-insensitively), ignoring any whitespace at
166167
the start or end of *message*.
167168

@@ -170,9 +171,10 @@ the disposition of the match. Each entry is a tuple of the form (*action*,
170171

171172
* *module* is a string containing a regular expression that the start of the
172173
fully qualified module name must match, case-sensitively. In :option:`-W` and
173-
:envvar:`PYTHONWARNINGS`, if *module* is at least two characters long and
174-
starts and ends with a forward slash (``/``), it specifies a regular
175-
expression as above; otherwise it is a literal string that the
174+
:envvar:`PYTHONWARNINGS`, if *module* starts and ends with a forward
175+
slash (``/``), it specifies a regular expression as above (a single ``/``
176+
on its own is treated as a literal string); otherwise it is a literal
177+
string that the
176178
fully qualified module name must be equal to (case-sensitively), ignoring any
177179
whitespace at the start or end of *module*.
178180

Doc/using/cmdline.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,9 @@ Miscellaneous options
481481

482482
The *message* field must match the start of the warning message;
483483
this match is case-insensitive.
484-
If it is at least two characters long and starts and ends with a forward
485-
slash (``/``), it specifies a regular expression, otherwise it specifies a
486-
literal string.
484+
If it starts and ends with a forward slash (``/``), it specifies a regular
485+
expression (a single ``/`` on its own is treated as a literal string),
486+
otherwise it specifies a literal string.
487487

488488
The *category* field matches the warning category
489489
(ex: ``DeprecationWarning``). This must be a class name; the match test
@@ -492,10 +492,11 @@ Miscellaneous options
492492

493493
The *module* field matches the (fully qualified) module name; this match is
494494
case-sensitive.
495-
If it is at least two characters long and starts and ends with a forward
496-
slash (``/``), it specifies a regular expression that the start of the fully
497-
qualified module name must match, otherwise it specifies a literal string
498-
that the fully qualified module name must be equal to.
495+
If it starts and ends with a forward slash (``/``), it specifies a regular
496+
expression (a single ``/`` on its own is treated as a literal string) that
497+
the start of the fully qualified module name must match, otherwise it
498+
specifies a literal string that the fully qualified module name must be
499+
equal to.
499500

500501
The *lineno* field matches the line number, where zero matches all line
501502
numbers and is thus equivalent to an omitted line number.

0 commit comments

Comments
 (0)