summaryrefslogtreecommitdiffstats
path: root/Lib/sre_parse.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-09-16 22:29:58 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-09-16 22:29:58 (GMT)
commitabf275af5804c5f76fbe10c5cb1dd3d2e4b04c5b (patch)
treed5d1e22046efaa0a779f4a387ba8622b900234fe /Lib/sre_parse.py
parent8761e59f360baefd4cead71d77de48ed91c3cfb7 (diff)
downloadcpython-abf275af5804c5f76fbe10c5cb1dd3d2e4b04c5b.zip
cpython-abf275af5804c5f76fbe10c5cb1dd3d2e4b04c5b.tar.gz
cpython-abf275af5804c5f76fbe10c5cb1dd3d2e4b04c5b.tar.bz2
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.
Diffstat (limited to 'Lib/sre_parse.py')
-rw-r--r--Lib/sre_parse.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py
index 4a77f0c..3d38673 100644
--- a/Lib/sre_parse.py
+++ b/Lib/sre_parse.py
@@ -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