[Python-checkins] cpython (merge 3.5 -> default): Issue #25554: Got rid of circular references in regular expression parsing.

serhiy.storchaka python-checkins at python.org
Thu Nov 5 10:52:27 EST 2015


https://hg.python.org/cpython/rev/8621727dd9f7
changeset: 98972:8621727dd9f7
parent: 98970:9135ff7255a1
parent: 98971:7f4fca8f13a2
user: Serhiy Storchaka <storchaka at gmail.com>
date: Thu Nov 05 17:51:15 2015 +0200
summary:
 Issue #25554: Got rid of circular references in regular expression parsing.
files:
 Lib/sre_parse.py | 12 ++++++------
 Misc/NEWS | 2 ++
 2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py
--- a/Lib/sre_parse.py
+++ b/Lib/sre_parse.py
@@ -70,14 +70,14 @@
 def __init__(self):
 self.flags = 0
 self.groupdict = {}
- self.subpatterns = [None] # group 0
+ self.groupwidths = [None] # group 0
 self.lookbehindgroups = None
 @property
 def groups(self):
- return len(self.subpatterns)
+ return len(self.groupwidths)
 def opengroup(self, name=None):
 gid = self.groups
- self.subpatterns.append(None)
+ self.groupwidths.append(None)
 if self.groups > MAXGROUPS:
 raise error("too many groups")
 if name is not None:
@@ -88,9 +88,9 @@
 self.groupdict[name] = gid
 return gid
 def closegroup(self, gid, p):
- self.subpatterns[gid] = p
+ self.groupwidths[gid] = p.getwidth()
 def checkgroup(self, gid):
- return gid < self.groups and self.subpatterns[gid] is not None
+ return gid < self.groups and self.groupwidths[gid] is not None
 
 def checklookbehindgroup(self, gid, source):
 if self.lookbehindgroups is not None:
@@ -195,7 +195,7 @@
 lo = lo + 1
 hi = hi + 1
 elif op is GROUPREF:
- i, j = self.pattern.subpatterns[av].getwidth()
+ i, j = self.pattern.groupwidths[av]
 lo = lo + i
 hi = hi + j
 elif op is GROUPREF_EXISTS:
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -72,6 +72,8 @@
 Library
 -------
 
+- Issue #25554: Got rid of circular references in regular expression parsing.
+
 - Issue #18973: Command-line interface of the calendar module now uses argparse
 instead of optparse.
 
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /