Commit f595a127 authored by Raymond Hettinger's avatar Raymond Hettinger

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

parent 3bef9355
...@@ -567,7 +567,8 @@ def _parse(source, state): ...@@ -567,7 +567,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:
...@@ -620,7 +621,8 @@ def _parse(source, state): ...@@ -620,7 +621,8 @@ def _parse(source, state):
if isname(condname): if isname(condname):
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(condgroup)
raise error(msg)
else: else:
try: try:
condgroup = int(condname) condgroup = int(condname)
...@@ -746,7 +748,8 @@ def parse_template(source, pattern): ...@@ -746,7 +748,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)
a((MARK, index)) a((MARK, index))
elif c == "0": elif c == "0":
if s.next in OCTDIGITS: if s.next in OCTDIGITS:
......
...@@ -31,6 +31,9 @@ Library ...@@ -31,6 +31,9 @@ Library
- Issue #21672: Fix the behavior of ntpath.join on UNC-style paths. - Issue #21672: Fix the behavior of ntpath.join on UNC-style paths.
- Issue #8343: Named group error messages in the re module did not show
the name of the erroneous group.
- Issue #21491: SocketServer: Fix a race condition in child processes reaping. - Issue #21491: SocketServer: Fix a race condition in child processes reaping.
- Issue #21635: The difflib SequenceMatcher.get_matching_blocks() method - Issue #21635: The difflib SequenceMatcher.get_matching_blocks() method
......
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