Kaydet (Commit) 1c99bc84 authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Issue #8343: Named group error msgs did not show the group name.

üst f6f78e1d
...@@ -616,7 +616,8 @@ def _parse(source, state): ...@@ -616,7 +616,8 @@ def _parse(source, state):
"%r" % name) "%r" % name)
gid = state.groupdict.get(name) gid = state.groupdict.get(name)
if gid is None: if gid is None:
raise error("unknown group name") msg = "unknown group name: {0!r}".format(name)
raise error(msg)
subpatternappend((GROUPREF, gid)) subpatternappend((GROUPREF, gid))
continue continue
else: else:
...@@ -669,7 +670,8 @@ def _parse(source, state): ...@@ -669,7 +670,8 @@ def _parse(source, state):
if condname.isidentifier(): if condname.isidentifier():
condgroup = state.groupdict.get(condname) condgroup = state.groupdict.get(condname)
if condgroup is None: if condgroup is None:
raise error("unknown group name") msg = "unknown group name: {0!r}".format(condname)
raise error(msg)
else: else:
try: try:
condgroup = int(condname) condgroup = int(condname)
...@@ -806,7 +808,8 @@ def parse_template(source, pattern): ...@@ -806,7 +808,8 @@ def parse_template(source, pattern):
try: try:
index = pattern.groupindex[name] index = pattern.groupindex[name]
except KeyError: except KeyError:
raise IndexError("unknown group name") msg = "unknown group name: {0!r}".format(name)
raise IndexError(msg)
addgroup(index) addgroup(index)
elif c == "0": elif c == "0":
if s.next in OCTDIGITS: if s.next in OCTDIGITS:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment