Page MenuHomePhabricator

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

Authored by martinvonz on Fri, Sep 11, 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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

martinvonz created this revision.Fri, Sep 11, 3:15 AM
pulkit added a subscriber: pulkit.Fri, Sep 11, 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.Sat, Sep 12, 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.Mon, Sep 14, 3:08 AM
This revision is now accepted and ready to land.Mon, Sep 14, 3:08 AM