mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
#12759: sre_parse now raises a proper error when the name of the group is missing. Initial patch by Serhiy Storchaka.
This commit is contained in:
parent
dedfa9bfae
commit
0941d9fc64
3 changed files with 30 additions and 1 deletions
|
@ -548,6 +548,8 @@ def _parse(source, state):
|
|||
break
|
||||
name = name + char
|
||||
group = 1
|
||||
if not name:
|
||||
raise error("missing group name")
|
||||
if not isname(name):
|
||||
raise error("bad character in group name")
|
||||
elif sourcematch("="):
|
||||
|
@ -560,6 +562,8 @@ def _parse(source, state):
|
|||
if char == ")":
|
||||
break
|
||||
name = name + char
|
||||
if not name:
|
||||
raise error("missing group name")
|
||||
if not isname(name):
|
||||
raise error("bad character in group name")
|
||||
gid = state.groupdict.get(name)
|
||||
|
@ -612,6 +616,8 @@ def _parse(source, state):
|
|||
break
|
||||
condname = condname + char
|
||||
group = 2
|
||||
if not condname:
|
||||
raise error("missing group name")
|
||||
if isname(condname):
|
||||
condgroup = state.groupdict.get(condname)
|
||||
if condgroup is None:
|
||||
|
@ -743,7 +749,7 @@ def parse_template(source, pattern):
|
|||
break
|
||||
name = name + char
|
||||
if not name:
|
||||
raise error("bad group name")
|
||||
raise error("missing group name")
|
||||
try:
|
||||
index = int(name)
|
||||
if index < 0:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue