[Updated] D8854: templates: add __init__.py files to templates/ dirs

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Sun Aug 2 16:25:01 UTC 2020


This revision is now accepted and ready to land.
indygreg added a comment.
indygreg accepted this revision.


  OMG. When I reviewed this, I thought your assertion that `resources.open_binary('mercurial.templates', 'coal/map')` is not valid was wrong because the low-level resource reader on the meta path importer does allow relative paths! However, it appears that the `open_binary()` helper functions limit this! This is yet another example of wonky behavior in these resources APIs. FWIW I've brought many of these to the attention of the core Python people at https://bugs.python.org/issue36128 and https://gitlab.com/python-devs/importlib_resources/-/issues/58 (and a few other places that I can't find the links to).
  
  Anyway, we could potentially avoid having `__init__.py` files if we bypassed the `importlib.resources` helper functions and accessed the APIs on `mercurial.__loader__` instead. I'll hold off queuing this part of the series to give you time to contemplate that (possibly simpler) alternative. I will say that a benefit to `importlib.resources` is they are higher-level and should abstract any changes to the low-level importer/loader interface. (The Python people were considering yet another API in Python 3.9, although I'm not sure if it was finalized.)

REPOSITORY
  rHG Mercurial

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8854/new/

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

To: martinvonz, #hg-reviewers, indygreg
Cc: indygreg, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200802/337860d7/attachment.html>


More information about the Mercurial-patches mailing list