mirror of
https://github.com/python/cpython.git
synced 2025-08-09 11:29:45 +00:00
[3.12] gh-100061: Proper fix of the bug in the matching of possessive quantifiers (GH-102612) (#108003)
Restore the global Input Stream pointer after trying to match a sub-pattern.
.
(cherry picked from commit abd9cc52d9
)
Co-authored-by: SKO <41810398+uyw4687@users.noreply.github.com>
This commit is contained in:
parent
00bfed7cba
commit
bd2ef82a50
4 changed files with 16 additions and 9 deletions
|
@ -100,13 +100,6 @@ def _compile(code, pattern, flags):
|
|||
emit(ANY_ALL)
|
||||
else:
|
||||
emit(ANY)
|
||||
elif op is POSSESSIVE_REPEAT:
|
||||
# gh-106052: Possessive quantifiers do not work when the
|
||||
# subpattern contains backtracking, i.e. "(?:ab?c)*+".
|
||||
# Implement it as equivalent greedy qualifier in atomic group.
|
||||
p = [(MAX_REPEAT, av)]
|
||||
p = [(ATOMIC_GROUP, p)]
|
||||
_compile(code, p, flags)
|
||||
elif op in REPEATING_CODES:
|
||||
if flags & SRE_FLAG_TEMPLATE:
|
||||
raise error("internal: unsupported template operator %r" % (op,))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue