Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 46926:9c3e84569071
re2: adjust local variable assignment scope
Pytype flagged the exception handler where these are used as `[name-error]`, and
PyCharm complained they may be used before assignment.
Differential Revision: https://phab.mercurial-scm.org/D10376
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 12 Apr 2021 23:31:54 -0400 |
parents | ffd3e823a7e5 |
children | d55b71393907 f38bf44e077f |
comparison
equal
deleted
inserted
replaced
46925:b5e8bf10436e | 46926:9c3e84569071 |
---|---|
2187 | 2187 |
2188 class _re(object): | 2188 class _re(object): |
2189 def _checkre2(self): | 2189 def _checkre2(self): |
2190 global _re2 | 2190 global _re2 |
2191 global _re2_input | 2191 global _re2_input |
2192 | |
2193 check_pattern = br'\[([^\[]+)\]' | |
2194 check_input = b'[ui]' | |
2192 try: | 2195 try: |
2193 # check if match works, see issue3964 | 2196 # check if match works, see issue3964 |
2194 check_pattern = br'\[([^\[]+)\]' | |
2195 check_input = b'[ui]' | |
2196 _re2 = bool(re2.match(check_pattern, check_input)) | 2197 _re2 = bool(re2.match(check_pattern, check_input)) |
2197 except ImportError: | 2198 except ImportError: |
2198 _re2 = False | 2199 _re2 = False |
2199 except TypeError: | 2200 except TypeError: |
2200 # the `pyre-2` project provides a re2 module that accept bytes | 2201 # the `pyre-2` project provides a re2 module that accept bytes |