changeset 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 b5e8bf10436e
children cdbef062c6c8
files mercurial/util.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Sat Mar 13 09:50:34 2021 +0100
+++ b/mercurial/util.py	Mon Apr 12 23:31:54 2021 -0400
@@ -2189,10 +2189,11 @@
     def _checkre2(self):
         global _re2
         global _re2_input
+
+        check_pattern = br'\[([^\[]+)\]'
+        check_input = b'[ui]'
         try:
             # check if match works, see issue3964
-            check_pattern = br'\[([^\[]+)\]'
-            check_input = b'[ui]'
             _re2 = bool(re2.match(check_pattern, check_input))
         except ImportError:
             _re2 = False