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.
This commit is contained in:
Tim Peters 2001-11-03 19:35:43 +00:00
parent c034b47ef3
commit 7533587d43
3 changed files with 28 additions and 19 deletions

View file

@ -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