--- a/mercurial/extensions.py Thu Jul 09 12:52:04 2020 +0200
+++ b/mercurial/extensions.py Tue Jul 14 11:28:06 2020 -0700
@@ -706,12 +706,17 @@
'''find paths of disabled extensions. returns a dict of {name: path}'''
import hgext
- extpath = os.path.dirname(
- os.path.abspath(pycompat.fsencode(hgext.__file__))
- )
- try: # might not be a filesystem path
- files = os.listdir(extpath)
- except OSError:
+ # The hgext might not have a __file__ attribute (e.g. in PyOxidizer) and
+ # it might not be on a filesystem even if it does.
+ if util.safehasattr(hgext, '__file__'):
+ extpath = os.path.dirname(
+ os.path.abspath(pycompat.fsencode(hgext.__file__))
+ )
+ try:
+ files = os.listdir(extpath)
+ except OSError:
+ return {}
+ else:
return {}
exts = {}