#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:
Ezio Melotti 2012-11-03 20:31:12 +02:00
parent d1076dbef8
commit ef3173877c
3 changed files with 30 additions and 1 deletions

View file

@ -541,6 +541,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("="):
@ -553,6 +555,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)
@ -605,6 +609,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:
@ -723,7 +729,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: