mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.10] gh-91700: Validate the group number in conditional expression in RE (GH-91702) (GH-91831)
In expression (?(group)...) an appropriate re.error is now
raised if the group number refers to not defined group.
Previously it raised RuntimeError: invalid SRE code.
(cherry picked from commit 48ec61a89a)
This commit is contained in:
parent
9c18d783c3
commit
080781cd49
3 changed files with 16 additions and 0 deletions
|
|
@ -575,6 +575,8 @@ def test_re_groupref_exists_errors(self):
|
|||
self.checkPatternError(r'()(?(1)a|b|c)',
|
||||
'conditional backref with more than '
|
||||
'two branches', 10)
|
||||
self.checkPatternError(r'()(?(2)a)',
|
||||
"invalid group reference 2", 5)
|
||||
|
||||
def test_re_groupref_overflow(self):
|
||||
from sre_constants import MAXGROUPS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue