changeset 43955:75ec46c63657

resourceutil: use `from importlib import resources` Without this patch, we get the following error from when trying to run hg with PyOxidizer: module 'importlib' has no attribute 'resources' I don't know what why that happens, but `from importlib import resources` is the form I would prefer anyway, so let's use that now that the impoort-checker has been fixed. Differential Revision: https://phab.mercurial-scm.org/D7701
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 18 Dec 2019 13:30:48 -0800
parents 303576116ac1
children a447efd991b9
files mercurial/utils/resourceutil.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/utils/resourceutil.py	Wed Dec 18 13:39:44 2019 -0800
+++ b/mercurial/utils/resourceutil.py	Wed Dec 18 13:30:48 2019 -0800
@@ -37,19 +37,19 @@
     datapath = os.path.dirname(os.path.dirname(pycompat.fsencode(__file__)))
 
 try:
-    import importlib
+    from importlib import resources
 
     # Force loading of the resources module
-    importlib.resources.open_binary  # pytype: disable=module-attr
+    resources.open_binary  # pytype: disable=module-attr
 
     def open_resource(package, name):
         package = b'mercurial.' + package
-        return importlib.resources.open_binary(  # pytype: disable=module-attr
+        return resources.open_binary(  # pytype: disable=module-attr
             pycompat.sysstr(package), pycompat.sysstr(name)
         )
 
 
-except AttributeError:
+except (ImportError, AttributeError):
 
     def _package_path(package):
         return os.path.join(datapath, *package.split(b'.'))