Patchwork [3,of,3] py3: use pycompat.sysstr() in __import__()

login
register
mail settings
Submitter Pulkit Goyal
Date Dec. 4, 2016, 2 p.m.
Message ID <93275b09d8977ad5700c.1480860052@pulkit-goyal>
Download mbox | patch
Permalink /patch/17818/
State Accepted
Headers show

Comments

Pulkit Goyal - Dec. 4, 2016, 2 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1480578124 -19800
#      Thu Dec 01 13:12:04 2016 +0530
# Node ID 93275b09d8977ad5700ca56a017f48ce602058ba
# Parent  3743d04e0403e49cd5a9c00d753262162712eeab
py3: use pycompat.sysstr() in __import__()

__import__() on Python 3 accepts strings which are different from that of
Python 2. Used pycompat.sysstr() to get string accordingly.

Patch

diff -r 3743d04e0403 -r 93275b09d897 mercurial/extensions.py
--- a/mercurial/extensions.py	Wed Nov 30 23:51:11 2016 +0530
+++ b/mercurial/extensions.py	Thu Dec 01 13:12:04 2016 +0530
@@ -18,6 +18,7 @@ 
 from . import (
     cmdutil,
     error,
+    pycompat,
     util,
 )
 
@@ -74,7 +75,7 @@ 
 
 def _importh(name):
     """import and return the <name> module"""
-    mod = __import__(name)
+    mod = __import__(pycompat.sysstr(name))
     components = name.split('.')
     for comp in components[1:]:
         mod = getattr(mod, comp)