Patchwork D9018: resourceutil: document when we expect to take the importlib.resouces code path

login
register
mail settings
Submitter phabricator
Date Sept. 12, 2020, 6:25 p.m.
Message ID <differential-rev-PHID-DREV-iqvu463ve3dadum4ie2h-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47147/
State Superseded
Headers show

Comments

phabricator - Sept. 12, 2020, 6:25 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/utils/resourceutil.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/utils/resourceutil.py b/mercurial/utils/resourceutil.py
--- a/mercurial/utils/resourceutil.py
+++ b/mercurial/utils/resourceutil.py
@@ -55,6 +55,8 @@ 
 
 
 try:
+    # importlib.resources exists from Python 3.7; see fallback in except clause
+    # further down
     from importlib import resources
 
     from .. import encoding
@@ -78,6 +80,8 @@ 
 
 
 except (ImportError, AttributeError):
+    # importlib.resources was not found (almost definitely because we're on a
+    # Python version before 3.7)
 
     def open_resource(package, name):
         path = os.path.join(_package_path(package), name)