mercurial/debugcommands.py
changeset 43686 1fb19665c166
parent 43635 72b454fae92e
child 43687 f1dabf99db17
--- a/mercurial/debugcommands.py	Sat Nov 16 16:25:28 2019 +0900
+++ b/mercurial/debugcommands.py	Sun Nov 17 01:00:06 2019 -0500
@@ -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')