templater: fix reading of templates in frozen binaries with py3 < 3.7
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 10 Sep 2020 22:00:00 -0700
changeset 45451 e53a3d0ef416
parent 45450 47d10ade5bc4
child 45452 dd9e28612468
templater: fix reading of templates in frozen binaries with py3 < 3.7 When using a frozen binary with py3 < 3.7, there's no `importlib.resources` module, so we use the code path that reads the resources from the file system. That code path expects bytes for package name and resource name. Differential Revision: https://phab.mercurial-scm.org/D9008
mercurial/templater.py
--- a/mercurial/templater.py	Fri Sep 11 09:35:49 2020 -0700
+++ b/mercurial/templater.py	Thu Sep 10 22:00:00 2020 -0700
@@ -1105,8 +1105,8 @@
         return f, open(f, mode='rb')
 
     # Otherwise try to read it using the resources API
-    name_parts = pycompat.sysstr(name).split('/')
-    package_name = '.'.join(['mercurial', 'templates'] + name_parts[:-1])
+    name_parts = name.split(b'/')
+    package_name = b'.'.join([b'mercurial', b'templates'] + name_parts[:-1])
     return (
         name,
         resourceutil.open_resource(package_name, name_parts[-1]),