mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-106052: Fix bug in the matching of possessive quantifiers (gh-106515)
It did not work in the case of a subpattern containing backtracking. Temporary implement possessive quantifiers as equivalent greedy qualifiers in atomic groups.
This commit is contained in:
parent
73507382ac
commit
7b6e34e5ba
3 changed files with 21 additions and 0 deletions
|
@ -100,6 +100,13 @@ 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 _simple(av[2]):
|
||||
emit(REPEATING_CODES[op][2])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue