diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-03-19 14:09:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-19 14:09:59 (GMT) |
commit | cbcd2e36d6cbb1d8b6a2b30a2cf1484b7857e7d6 (patch) | |
tree | c0ff1330c9a578654370fae61e00783f2f65df02 /Lib/sre_parse.py | |
parent | fcd57996899569ec6b8028bc5b75f973f7074e21 (diff) | |
download | cpython-cbcd2e36d6cbb1d8b6a2b30a2cf1484b7857e7d6.zip cpython-cbcd2e36d6cbb1d8b6a2b30a2cf1484b7857e7d6.tar.gz cpython-cbcd2e36d6cbb1d8b6a2b30a2cf1484b7857e7d6.tar.bz2 |
bpo-39394: Improve warning message in the re module (GH-31988)
A warning about inline flags not at the start of the regular
expression now contains the position of the flag.
(cherry picked from commit 4142961b9f5ad3bf93976a6a7162f8049e354018)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/sre_parse.py')
-rw-r--r-- | Lib/sre_parse.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 8311916..5370667 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -807,9 +807,11 @@ def _parse(source, state, verbose, nested, first=False): if not first or subpattern: import warnings warnings.warn( - 'Flags not at the start of the expression %r%s' % ( + 'Flags not at the start of the expression %r%s' + ' but at position %d' % ( source.string[:20], # truncate long regexes ' (truncated)' if len(source.string) > 20 else '', + start, ), DeprecationWarning, stacklevel=nested + 6 ) |