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.
--- 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)
--- a/tests/test-check-py3-compat.t Wed Nov 30 23:51:11 2016 +0530
+++ b/tests/test-check-py3-compat.t Thu Dec 01 13:12:04 2016 +0530
@@ -31,7 +31,6 @@
hgext/fsmonitor/pywatchman/capabilities.py: error importing: <ImportError> No module named 'pybser' (error at __init__.py:*)
hgext/fsmonitor/pywatchman/pybser.py: error importing: <ImportError> No module named 'pybser' (error at __init__.py:*)
hgext/fsmonitor/watchmanclient.py: error importing: <ImportError> No module named 'pybser' (error at __init__.py:*)
- hgext/mq.py: error importing: <TypeError> __import__() argument 1 must be str, not bytes (error at extensions.py:*)
mercurial/cffi/bdiff.py: error importing: <ImportError> No module named 'mercurial.cffi' (error at check-py3-compat.py:*)
mercurial/cffi/mpatch.py: error importing: <ImportError> No module named 'mercurial.cffi' (error at check-py3-compat.py:*)
mercurial/cffi/osutil.py: error importing: <ImportError> No module named 'mercurial.cffi' (error at check-py3-compat.py:*)