Patchwork D2154: py3: use system strings when calling __import__

login
register
mail settings
Submitter phabricator
Date Feb. 12, 2018, 2:35 a.m.
Message ID <differential-rev-PHID-DREV-qtgf37n24u2ogl5bexnp-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27620/
State Superseded
Headers show

Comments

phabricator - Feb. 12, 2018, 2:35 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We must pass the native str type when importing.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2154

AFFECTED FILES
  mercurial/hook.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/hook.py b/mercurial/hook.py
--- a/mercurial/hook.py
+++ b/mercurial/hook.py
@@ -49,12 +49,12 @@ 
                 modname = modfile
         with demandimport.deactivated():
             try:
-                obj = __import__(modname)
+                obj = __import__(pycompat.sysstr(modname))
             except (ImportError, SyntaxError):
                 e1 = sys.exc_info()
                 try:
                     # extensions are loaded with hgext_ prefix
-                    obj = __import__("hgext_%s" % modname)
+                    obj = __import__(r"hgext_%s" % pycompat.sysstr(modname))
                 except (ImportError, SyntaxError):
                     e2 = sys.exc_info()
                     if ui.tracebackflag: