Patchwork D9008: templater: fix reading of templates in frozen binaries with py3 < 3.7

login
register
mail settings
Submitter phabricator
Date Sept. 11, 2020, 7:16 a.m.
Message ID <differential-rev-PHID-DREV-phcbiqyyq4675boavfsz-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47136/
State Superseded
Headers show

Comments

phabricator - Sept. 11, 2020, 7:16 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/templater.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -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]),