mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
8761e59f36
commit
abf275af58
3 changed files with 26 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue