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

login
register
mail settings
Submitter phabricator
Date Dec. 18, 2019, 10:30 p.m.
Message ID <differential-rev-PHID-DREV-4i6utdsvyzi5dc6fvhpk-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43981/
State Superseded
Headers show

Comments

phabricator - Dec. 18, 2019, 10:30 p.m.
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




To: martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 19, 2019, 2:05 a.m.
This revision is now accepted and ready to land.
indygreg added a comment.
indygreg accepted this revision.


  Yay - more undefined behavior regarding the `importlib.resources` interface!

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

To: martinvonz, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel
phabricator - Dec. 19, 2019, 5:42 a.m.
martinvonz added a comment.
martinvonz abandoned this revision.


  What this was fixing was not yet accepted -- it's in D7629 <https://phab.mercurial-scm.org/D7629>. I've reordered the patches now and this on is no longer needed.

REPOSITORY
  rHG Mercurial

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

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

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

Patch

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)