summaryrefslogtreecommitdiffstats
path: root/Lib/sre_parse.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/sre_parse.py')
-rw-r--r--Lib/sre_parse.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py
index d74e93f..4a77f0c 100644
--- a/Lib/sre_parse.py
+++ b/Lib/sre_parse.py
@@ -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