]> granicus.if.org Git - python/commitdiff
Issue #8343: Named group error msgs did not show the group name.
authorRaymond Hettinger <python@rcn.com>
Mon, 23 Jun 2014 02:33:19 +0000 (19:33 -0700)
committerRaymond Hettinger <python@rcn.com>
Mon, 23 Jun 2014 02:33:19 +0000 (19:33 -0700)
Lib/sre_parse.py
Misc/NEWS

index e37e2cfce3f81a6ffaba4b2e5eb3a9a35d13748c..662e49a187b4a2f7c02d2f87d369962a80930804 100644 (file)
@@ -567,7 +567,8 @@ def _parse(source, state):
                                         "%r" % name)
                         gid = state.groupdict.get(name)
                         if gid is None:
-                            raise error, "unknown group name"
+                            msg = "unknown group name: {0!r}".format(name)
+                            raise error(msg)
                         subpatternappend((GROUPREF, gid))
                         continue
                     else:
@@ -620,7 +621,8 @@ def _parse(source, state):
                     if isname(condname):
                         condgroup = state.groupdict.get(condname)
                         if condgroup is None:
-                            raise error, "unknown group name"
+                            msg = "unknown group name: {0!r}".format(condgroup)
+                            raise error(msg)
                     else:
                         try:
                             condgroup = int(condname)
@@ -746,7 +748,8 @@ def parse_template(source, pattern):
                     try:
                         index = pattern.groupindex[name]
                     except KeyError:
-                        raise IndexError, "unknown group name"
+                        msg = "unknown group name: {0!r}".format(name)
+                        raise IndexError(msg)
                 a((MARK, index))
             elif c == "0":
                 if s.next in OCTDIGITS:
index aa054039e15be43d9342d44df5f9a71fa025b96b..3238d06ec74c3725ed361b3e49816b5fc5d630a4 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -31,6 +31,9 @@ Library
 
 - 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 #21635:  The difflib SequenceMatcher.get_matching_blocks() method