Upstream-Status: Backport, https://bazaar.launchpad.net/~bzr-pqm/bzr/2.7/revision/6621 Upstream-Ticket: https://bugs.launchpad.net/bzr/+bug/1644003 Ticket: https://trac.macports.org/ticket/53620 === modified file 'bzrlib/lazy_regex.py' --- bzrlib/lazy_regex.py 2011-12-19 13:23:58 +0000 +++ bzrlib/lazy_regex.py 2017-01-15 20:36:48 +0000 @@ -131,3 +131,13 @@ raise AssertionError( "re.compile has already been overridden as lazy_compile, but this would" \ " cause infinite recursion") + + +# re.finditer get confused if it receives a LazyRegex +if getattr(re, 'finditer', None is not None): + def finditer_public(pattern, string, flags=0): + if isinstance(pattern, LazyRegex): + return pattern.finditer(string) + else: + return _real_re_compile(pattern, flags).finditer(string) +re.finditer = finditer_public