D7451: debuginstall: gracefully handle missing __file__ attributes
mharbison72 (Matt Harbison)
phabricator at mercurial-scm.org
Sun Nov 17 12:54:29 EST 2019
mharbison72 updated this revision to Diff 18204.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D7451?vs=18202&id=18204
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D7451/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D7451
AFFECTED FILES
mercurial/debugcommands.py
CHANGE DETAILS
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1470,6 +1470,12 @@
)
# Python
+ pythonlib = None
+ if util.safehasattr(os, '__file__'):
+ pythonlib = os.path.dirname(pycompat.fsencode(os.__file__))
+ elif getattr(sys, 'oxidized', False):
+ pythonlib = pycompat.sysexecutable
+
fm.write(
b'pythonexe',
_(b"checking Python executable (%s)\n"),
@@ -1483,7 +1489,7 @@
fm.write(
b'pythonlib',
_(b"checking Python lib (%s)...\n"),
- os.path.dirname(pycompat.fsencode(os.__file__)),
+ pythonlib or _(b"unknown"),
)
security = set(sslutil.supportedprotocols)
@@ -1527,13 +1533,19 @@
)
# compiled modules
+ hgmodules = None
+ if util.safehasattr(sys.modules[__name__], '__file__'):
+ hgmodules = os.path.dirname(pycompat.fsencode(__file__))
+ elif getattr(sys, 'oxidized', False):
+ hgmodules = pycompat.sysexecutable
+
fm.write(
b'hgmodulepolicy', _(b"checking module policy (%s)\n"), policy.policy
)
fm.write(
b'hgmodules',
_(b"checking installed modules (%s)...\n"),
- os.path.dirname(pycompat.fsencode(__file__)),
+ hgmodules or _(b"unknown"),
)
rustandc = policy.policy in (b'rust+c', b'rust+c-allow')
To: mharbison72, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list