# HG changeset patch # User Augie Fackler <au...@google.com> # Date 1476019688 14400 # Sun Oct 09 09:28:08 2016 -0400 # Node ID e6a69e778cb02cada23352df512b8580026640d9 # Parent e89f400277d564c4a576ad8e4a6003a201993639 extensions: fix extension module hunting on Python 3
importlib is a firm believer that paths are really strings, not bytes. Fortunately we have os.fsdecode to help us with that. This also makes a few strings r-strings to make them bytes on Py2 and str on py3. That might be too clever? diff --git a/mercurial/extensions.py b/mercurial/extensions.py --- a/mercurial/extensions.py +++ b/mercurial/extensions.py @@ -18,6 +18,7 @@ from .i18n import ( from . import ( cmdutil, error, + pycompat, util, ) @@ -57,8 +58,9 @@ def find(name): return mod def loadpath(path, module_name): - module_name = module_name.replace('.', '_') + module_name = module_name.replace(r'.', r'_') path = util.normpath(util.expandpath(path)) + path = os.fsdecode(path) if os.path.isdir(path): # module/__init__.py style d, f = os.path.split(path) @@ -85,7 +87,7 @@ def _importext(name, path=None, reportfu # the module will be loaded in sys.modules # choose an unique name so that it doesn't # conflicts with other modules - mod = loadpath(path, 'hgext.%s' % name) + mod = loadpath(path, pycompat.sysstr('hgext.%s' % name)) else: try: mod = _importh("hgext.%s" % name) _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel