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

@ -231,20 +231,21 @@ class Sniffer:
quotes = {}
delims = {}
spaces = 0
groupindex = regexp.groupindex
for m in matches:
n = regexp.groupindex['quote'] - 1
n = groupindex['quote'] - 1
key = m[n]
if key:
quotes[key] = quotes.get(key, 0) + 1
try:
n = regexp.groupindex['delim'] - 1
n = groupindex['delim'] - 1
key = m[n]
except KeyError:
continue
if key and (delimiters is None or key in delimiters):
delims[key] = delims.get(key, 0) + 1
try:
n = regexp.groupindex['space'] - 1
n = groupindex['space'] - 1
except KeyError:
continue
if m[n]: