##// END OF EJS Templates
re2: make errors quiet...
marmoute -
r52503:6c39edd1 stable
parent child Browse files
Show More
@@ -2196,6 +2196,8 b' def fscasesensitive(path: bytes) -> bool'
2196 2196
2197 2197
2198 2198 _re2_input = lambda x: x
2199 # google-re2 will need to be tell to not output error on its own
2200 _re2_options = None
2199 2201 try:
2200 2202 import re2 # pytype: disable=import-error
2201 2203
@@ -2216,6 +2218,7 b' class _re:'
2216 2218 def _checkre2():
2217 2219 global _re2
2218 2220 global _re2_input
2221 global _re2_options
2219 2222 if _re2 is not None:
2220 2223 # we already have the answer
2221 2224 return
@@ -2234,6 +2237,12 b' class _re:'
2234 2237 check_input = pycompat.sysstr(check_input)
2235 2238 _re2 = bool(re2.match(check_pattern, check_input))
2236 2239 _re2_input = pycompat.sysstr
2240 try:
2241 quiet = re2.Options()
2242 quiet.log_errors = False
2243 _re2_options = quiet
2244 except AttributeError:
2245 pass
2237 2246
2238 2247 def compile(self, pat, flags=0):
2239 2248 """Compile a regular expression, using re2 if possible
@@ -2249,7 +2258,12 b' class _re:'
2249 2258 if flags & remod.MULTILINE:
2250 2259 pat = b'(?m)' + pat
2251 2260 try:
2252 return re2.compile(_re2_input(pat))
2261 input_regex = _re2_input(pat)
2262 if _re2_options is not None:
2263 compiled = re2.compile(input_regex, options=_re2_options)
2264 else:
2265 compiled = re2.compile(input_regex)
2266 return compiled
2253 2267 except re2.error:
2254 2268 pass
2255 2269 return remod.compile(pat, flags)
General Comments 0
You need to be logged in to leave comments. Login now