D7702: pyoxidizer: don't expect `fp.name` to exist on object from `resources`

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Wed Dec 18 17:30:58 EST 2019


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  `importlib.resources.open_resource()` in pyoxidizer returns a
  `_io.BytesIO`, which does not have a `name` attribute.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/rcutil.py

CHANGE DETAILS

diff --git a/mercurial/rcutil.py b/mercurial/rcutil.py
--- a/mercurial/rcutil.py
+++ b/mercurial/rcutil.py
@@ -91,7 +91,8 @@
                 continue
             with resourceutil.open_resource(b'defaultrc', name) as fp:
                 cfg = config.config()
-                cfg.read(pycompat.sysbytes(fp.name), fp=fp)
+                source = util.getattr(fp, 'name', b'<internal>/' + name)
+                cfg.read(pycompat.sysbytes(source), fp=fp)
                 for section in cfg:
                     for name, value in cfg.items(section):
                         source = cfg.source(section, name)



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


More information about the Mercurial-devel mailing list