D7701: resourceutil: use `from importlib import resources`
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Mon Dec 23 12:27:27 EST 2019
Closed by commit rHG75ec46c63657: resourceutil: use `from importlib import resources` (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D7701?vs=18871&id=18914
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D7701/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D7701
AFFECTED FILES
mercurial/utils/resourceutil.py
CHANGE DETAILS
diff --git a/mercurial/utils/resourceutil.py b/mercurial/utils/resourceutil.py
--- a/mercurial/utils/resourceutil.py
+++ b/mercurial/utils/resourceutil.py
@@ -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'.'))
To: martinvonz, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel
More information about the Mercurial-devel
mailing list