This is an archive of the discontinued Mercurial Phabricator instance.

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

Authored by martinvonz on Sep 11 2020, 3:15 AM.

Details

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.

Diff Detail

Repository
rHG Mercurial
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

martinvonz created this revision.Sep 11 2020, 3:15 AM
pulkit added a subscriber: pulkit.Sep 11 2020, 5:13 AM

Does this also works with python > 3.7 or we need to add a conditional here?

Does this also works with python > 3.7 or we need to add a conditional here?

Yes, it works on python >= 3.7 already before this patch. Then it uses importlib.resources. I tested the original patch that introduced this support for reading from resources using PyOxidizer (which uses >=3.7). I noticed that I had not gotten the < 3.7 case right only when I tried to run this code with our e2e tests at work, where we use a non-PyOxidizer way of freezing binaries with Python 3.6.

marmoute accepted this revision.Sep 12 2020, 6:03 AM
marmoute added a subscriber: marmoute.

looks good. As an unrelated change, maybe add a comment on the previous block to indicate it is relevant for all python starting from 3.9+

looks good. As an unrelated change, maybe add a comment on the previous block to indicate it is relevant for all python starting from 3.9+

Makes sense (though it's 3.7+, not 3.9+). I've added D9018 as a child.

pulkit accepted this revision.Sep 14 2020, 3:08 AM
This revision is now accepted and ready to land.Sep 14 2020, 3:08 AM