##// 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 _re2_input = lambda x: x
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 try:
2201 try:
2200 import re2 # pytype: disable=import-error
2202 import re2 # pytype: disable=import-error
2201
2203
@@ -2216,6 +2218,7 b' class _re:'
2216 def _checkre2():
2218 def _checkre2():
2217 global _re2
2219 global _re2
2218 global _re2_input
2220 global _re2_input
2221 global _re2_options
2219 if _re2 is not None:
2222 if _re2 is not None:
2220 # we already have the answer
2223 # we already have the answer
2221 return
2224 return
@@ -2234,6 +2237,12 b' class _re:'
2234 check_input = pycompat.sysstr(check_input)
2237 check_input = pycompat.sysstr(check_input)
2235 _re2 = bool(re2.match(check_pattern, check_input))
2238 _re2 = bool(re2.match(check_pattern, check_input))
2236 _re2_input = pycompat.sysstr
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 def compile(self, pat, flags=0):
2247 def compile(self, pat, flags=0):
2239 """Compile a regular expression, using re2 if possible
2248 """Compile a regular expression, using re2 if possible
@@ -2249,7 +2258,12 b' class _re:'
2249 if flags & remod.MULTILINE:
2258 if flags & remod.MULTILINE:
2250 pat = b'(?m)' + pat
2259 pat = b'(?m)' + pat
2251 try:
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 except re2.error:
2267 except re2.error:
2254 pass
2268 pass
2255 return remod.compile(pat, flags)
2269 return remod.compile(pat, flags)
General Comments 0
You need to be logged in to leave comments. Login now