[Python-checkins] cpython (2.7): Issue #8343: Named group error msgs did not show the group name.

raymond.hettinger python-checkins at python.org
Mon Jun 23 04:33:27 CEST 2014


http://hg.python.org/cpython/rev/9c7b50a36b42
changeset:   91341:9c7b50a36b42
branch:      2.7
user:        Raymond Hettinger <python at rcn.com>
date:        Sun Jun 22 19:33:19 2014 -0700
summary:
  Issue #8343: Named group error msgs did not show the group name.

files:
  Lib/sre_parse.py |  9 ++++++---
  Misc/NEWS        |  3 +++
  2 files changed, 9 insertions(+), 3 deletions(-)


diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py
--- a/Lib/sre_parse.py
+++ b/Lib/sre_parse.py
@@ -567,7 +567,8 @@
                                         "%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 @@
                     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 @@
                     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:
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -31,6 +31,9 @@
 
 - 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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list