mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-47066: Convert a warning about flags not at the start of the regular expression into error (GH-31994)
This commit is contained in:
parent
cb7874f49d
commit
92a6abf72e
5 changed files with 25 additions and 65 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue