summaryrefslogtreecommitdiffstats
path: root/Lib/re.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-11-07 19:45:17 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-11-07 19:45:17 (GMT)
commit6276b32799d9396bb32dbbcbed61b3045ce166ec (patch)
tree1326560e2f5259de7448acfde14951cc7c3a1772 /Lib/re.py
parentea07bd2f8121f85e789e7eba581f638a6b1bfa37 (diff)
parent84df7fe6a2ff20663a194d3758295bee9b1436ef (diff)
downloadcpython-6276b32799d9396bb32dbbcbed61b3045ce166ec.zip
cpython-6276b32799d9396bb32dbbcbed61b3045ce166ec.tar.gz
cpython-6276b32799d9396bb32dbbcbed61b3045ce166ec.tar.bz2
Issues #814253, #9179: Group references and conditional group references now
work in lookbehind assertions in regular expressions.
Diffstat (limited to 'Lib/re.py')
-rw-r--r--Lib/re.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/re.py b/Lib/re.py
index 0b1cb46..a4de5cc 100644
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -351,10 +351,11 @@ class Scanner:
s = sre_parse.Pattern()
s.flags = flags
for phrase, action in lexicon:
+ gid = s.opengroup()
p.append(sre_parse.SubPattern(s, [
- (SUBPATTERN, (len(p)+1, sre_parse.parse(phrase, flags))),
+ (SUBPATTERN, (gid, sre_parse.parse(phrase, flags))),
]))
- s.groups = len(p)+1
+ s.closegroup(gid, p[-1])
p = sre_parse.SubPattern(s, [(BRANCH, (None, p))])
self.scanner = sre_compile.compile(p)
def scan(self, string):