~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lazy_regex.py

Fix python re monkey-patching leak. [r=jelmer]

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
    raise AssertionError(
132
132
        "re.compile has already been overridden as lazy_compile, but this would" \
133
133
        " cause infinite recursion")
 
134
 
 
135
 
 
136
# re.finditer get confused if it receives a LazyRegex
 
137
if getattr(re, 'finditer', None is not None):
 
138
    def finditer_public(pattern, string, flags=0):
 
139
        if isinstance(pattern, LazyRegex):
 
140
            return pattern.finditer(string)
 
141
        else:
 
142
            return _real_re_compile(pattern, flags).finditer(string)
 
143
re.finditer = finditer_public