Patchwork D10376: re2: adjust local variable assignment scope

login
register
mail settings
Submitter phabricator
Date April 13, 2021, 4:03 a.m.
Message ID <differential-rev-PHID-DREV-c4aghl2fzhvn64krzdkx-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48693/
State Superseded
Headers show

Comments

phabricator - April 13, 2021, 4:03 a.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Pytype flagged the exception handler where these are used as `[name-error]`, and
  PyCharm complained they may be used before assignment.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10376

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2190,10 +2190,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