diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2022-03-19 14:10:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-19 14:10:44 (GMT) |
commit | 92a6abf72e7a8274f96edbb5297119d4ff055be7 (patch) | |
tree | 158af2148f4027e63d9b19cfaf968b6da7848c2e /Lib/sre_parse.py | |
parent | cb7874f49d3d55df73a3c529773af14e2e344fb7 (diff) | |
download | cpython-92a6abf72e7a8274f96edbb5297119d4ff055be7.zip cpython-92a6abf72e7a8274f96edbb5297119d4ff055be7.tar.gz cpython-92a6abf72e7a8274f96edbb5297119d4ff055be7.tar.bz2 |
bpo-47066: Convert a warning about flags not at the start of the regular expression into error (GH-31994)
Diffstat (limited to 'Lib/sre_parse.py')
-rw-r--r-- | Lib/sre_parse.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 5370667..bb95107 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -805,16 +805,9 @@ def _parse(source, state, verbose, nested, first=False): flags = _parse_flags(source, state, char) if flags is None: # global flags if not first or subpattern: - import warnings - warnings.warn( - '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 - ) + raise source.error('global flags not at the start ' + 'of the expression', + source.tell() - start) if (state.flags & SRE_FLAG_VERBOSE) and not verbose: raise Verbose continue |