mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #22493: Inline flags now should be used only at the start of the
regular expression. Deprecation warning is emitted if uses them in the middle of the regular expression.
This commit is contained in:
parent
352601ca00
commit
bd48d27944
12 changed files with 58 additions and 34 deletions
|
@ -279,6 +279,9 @@ class Tokenizer:
|
|||
break
|
||||
result += c
|
||||
return result
|
||||
@property
|
||||
def pos(self):
|
||||
return self.index - len(self.next or '')
|
||||
def tell(self):
|
||||
return self.index - len(self.next or '')
|
||||
def seek(self, index):
|
||||
|
@ -727,8 +730,13 @@ def _parse(source, state, verbose):
|
|||
state.checklookbehindgroup(condgroup, source)
|
||||
elif char in FLAGS or char == "-":
|
||||
# flags
|
||||
pos = source.pos
|
||||
flags = _parse_flags(source, state, char)
|
||||
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)
|
||||
continue
|
||||
add_flags, del_flags = flags
|
||||
group = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue