Issue #14260: The groupindex attribute of regular expression pattern object

now is non-modifiable mapping.
This commit is contained in:
Serhiy Storchaka 2015-03-30 01:01:48 +03:00
parent 1813c1701f
commit 07360df481
5 changed files with 31 additions and 5 deletions

View file

@ -855,6 +855,7 @@ def parse_template(source, pattern):
del literal[:]
groups.append((len(literals), index))
literals.append(None)
groupindex = pattern.groupindex
while True:
this = sget()
if this is None:
@ -869,7 +870,7 @@ def parse_template(source, pattern):
name = s.getuntil(">")
if name.isidentifier():
try:
index = pattern.groupindex[name]
index = groupindex[name]
except KeyError:
raise IndexError("unknown group name %r" % name)
else: