~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lazy_regex.py

  • Committer: Tarmac
  • Author(s): Florent Gallaire
  • Date: 2017-03-17 12:23:47 UTC
  • mfrom: (6621.1.1 fix-gmtime-lite)
  • Revision ID: tarmac-20170317122347-2nnf3cicpgrhux3h
Fix for Windows and 32-bit platforms buggy gmtime(). [r=vila,richard-wilbur]

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2008-2011, 2017 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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
# Some libraries calls re.finditer which fails it if receives a LazyRegex.
 
137
if getattr(re, 'finditer', False):
 
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