summaryrefslogtreecommitdiffstats
path: root/Lib/re.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-11-07 19:43:57 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-11-07 19:43:57 (GMT)
commit84df7fe6a2ff20663a194d3758295bee9b1436ef (patch)
tree09b3010bf531895d3188e0ace94a2df035ec5e7d /Lib/re.py
parentb556399fb500136ee4b3c562a72af062527bd20a (diff)
downloadcpython-84df7fe6a2ff20663a194d3758295bee9b1436ef.zip
cpython-84df7fe6a2ff20663a194d3758295bee9b1436ef.tar.gz
cpython-84df7fe6a2ff20663a194d3758295bee9b1436ef.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 199afee..82244db 100644
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -352,10 +352,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):