Show More
@@ -37,19 +37,19 b' else:' | |||||
37 | datapath = os.path.dirname(os.path.dirname(pycompat.fsencode(__file__))) |
|
37 | datapath = os.path.dirname(os.path.dirname(pycompat.fsencode(__file__))) | |
38 |
|
38 | |||
39 | try: |
|
39 | try: | |
40 | import importlib |
|
40 | from importlib import resources | |
41 |
|
41 | |||
42 | # Force loading of the resources module |
|
42 | # Force loading of the resources module | |
43 |
|
|
43 | resources.open_binary # pytype: disable=module-attr | |
44 |
|
44 | |||
45 | def open_resource(package, name): |
|
45 | def open_resource(package, name): | |
46 | package = b'mercurial.' + package |
|
46 | package = b'mercurial.' + package | |
47 |
return |
|
47 | return resources.open_binary( # pytype: disable=module-attr | |
48 | pycompat.sysstr(package), pycompat.sysstr(name) |
|
48 | pycompat.sysstr(package), pycompat.sysstr(name) | |
49 | ) |
|
49 | ) | |
50 |
|
50 | |||
51 |
|
51 | |||
52 | except AttributeError: |
|
52 | except (ImportError, AttributeError): | |
53 |
|
53 | |||
54 | def _package_path(package): |
|
54 | def _package_path(package): | |
55 | return os.path.join(datapath, *package.split(b'.')) |
|
55 | return os.path.join(datapath, *package.split(b'.')) |
General Comments 0
You need to be logged in to leave comments.
Login now