Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r70322:285b8bfe8e26 Date: 2014-03-29 11:44 +0100 http://bitbucket.org/pypy/pypy/changeset/285b8bfe8e26/
Log: RPythonify the findall and finditer methods (hopefully) diff --git a/rpython/rlib/rsre/rsre_re.py b/rpython/rlib/rsre/rsre_re.py --- a/rpython/rlib/rsre/rsre_re.py +++ b/rpython/rlib/rsre/rsre_re.py @@ -71,7 +71,11 @@ def findall(self, string, pos=0, endpos=sys.maxint): matchlist = [] - for match in self.finditer(string, pos, endpos): + scanner = self.scanner(string, pos, endpos) + while True: + match = scanner.search() + if match is None: + break if self.groups == 0 or self.groups == 1: item = match.group(self.groups) else: @@ -80,7 +84,12 @@ return matchlist def finditer(self, string, pos=0, endpos=sys.maxint): - return iter(self.scanner(string, pos, endpos).search, None) + scanner = self.scanner(string, pos, endpos) + while True: + match = scanner.search() + if match is None: + break + yield match def subn(self, repl, string, count=0): filter = repl _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit