Issue #22493: Warning message emitted by using inline flags in the middle of

regular expression now contains a (truncated) regex pattern.
Patch by Tim Graham.
This commit is contained in:
Serhiy Storchaka 2016-09-17 01:29:58 +03:00
parent 8761e59f36
commit abf275af58
3 changed files with 26 additions and 4 deletions

View file

@ -735,8 +735,13 @@ def _parse(source, state, verbose):
if flags is None: # global flags
if pos != 3: # "(?x"
import warnings
warnings.warn('Flags not at the start of the expression',
DeprecationWarning, stacklevel=7)
warnings.warn(
'Flags not at the start of the expression %s%s' % (
source.string[:20], # truncate long regexes
' (truncated)' if len(source.string) > 20 else '',
),
DeprecationWarning, stacklevel=7
)
continue
add_flags, del_flags = flags
group = None