diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-11-03 19:35:43 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-11-03 19:35:43 (GMT) |
commit | 7533587d4363d0841232f58d61adc15fa32b4825 (patch) | |
tree | f41119a2152cccf1475f700bb103cefcd5c1a550 /Lib/sre_parse.py | |
parent | c034b47ef39cf757d241888e93df11876ee53f48 (diff) | |
download | cpython-7533587d4363d0841232f58d61adc15fa32b4825.zip cpython-7533587d4363d0841232f58d61adc15fa32b4825.tar.gz cpython-7533587d4363d0841232f58d61adc15fa32b4825.tar.bz2 |
Improved error msg when a symbolic group name is redefined. Added docs
and NEWS. Bugfix candidate? That's a dilemma for Anthony <wink>: /F
did fix a longstanding bug here, but the fix can cause code to raise an
exception that previously worked by accident.
Diffstat (limited to 'Lib/sre_parse.py')
-rw-r--r-- | Lib/sre_parse.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 4596f3b..7313a1f 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -81,8 +81,10 @@ class Pattern: gid = self.groups self.groups = gid + 1 if name: - if self.groupdict.has_key(name): - raise error, "can only use each group name once" + ogid = self.groupdict.get(name, None) + if ogid is not None: + raise error, ("redefinition of group name %s as group %d; " + + "was group %d") % (`name`, gid, ogid) self.groupdict[name] = gid self.open.append(gid) return gid |