changeset 43687:f1dabf99db17

debugextensions: gracefully handle missing __file__ attributes This was crashing PyOxidizer. Differential Revision: https://phab.mercurial-scm.org/D7452
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 17 Nov 2019 01:34:52 -0500
parents 1fb19665c166
children 5cdc3c1292f6
files mercurial/debugcommands.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Sun Nov 17 01:00:06 2019 -0500
+++ b/mercurial/debugcommands.py	Sun Nov 17 01:34:52 2019 -0500
@@ -1029,7 +1029,12 @@
     fm = ui.formatter(b'debugextensions', opts)
     for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
         isinternal = extensions.ismoduleinternal(extmod)
-        extsource = pycompat.fsencode(extmod.__file__)
+        extsource = None
+
+        if util.safehasattr(extmod, '__file__'):
+            extsource = pycompat.fsencode(extmod.__file__)
+        elif getattr(sys, 'oxidized', False):
+            extsource = pycompat.sysexecutable
         if isinternal:
             exttestedwith = []  # never expose magic string to users
         else: