summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchfw <wangc_2011@hotmail.com>2018-11-06 18:22:16 (GMT)
committerchfw <wangc_2011@hotmail.com>2018-11-06 18:22:16 (GMT)
commita7a9f348806e168a6a946a9ba0ab6ec5475e5689 (patch)
tree07a5aa01b6a793492782abf969d38f2a80b8b3d5
parent311b696f1a3ebca8dbce2fab9d24beba747fe5bc (diff)
downloadpython-lml-a7a9f348806e168a6a946a9ba0ab6ec5475e5689.zip
python-lml-a7a9f348806e168a6a946a9ba0ab6ec5475e5689.tar.gz
python-lml-a7a9f348806e168a6a946a9ba0ab6ec5475e5689.tar.bz2
:bug: fix NameError: name 'ModuleNotFoundError' is not defined
-rw-r--r--lml/utils.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/lml/utils.py b/lml/utils.py
index a0d9995..d64c04b 100644
--- a/lml/utils.py
+++ b/lml/utils.py
@@ -12,6 +12,7 @@ import logging
from json import JSONEncoder, dumps
PY2 = sys.version_info[0] == 2
+PY36 = sys.version_info[0] == 3 and sys.version_info[1] >= 6
log = logging.getLogger(__name__)
@@ -38,15 +39,15 @@ def json_dumps(keywords):
def do_import(plugin_module_name):
"""dynamically import a module"""
- if PY2:
+ if PY36:
try:
return _do_import(plugin_module_name)
- except ImportError:
+ except (ImportError, ModuleNotFoundError):
log.exception("failed to import %s", plugin_module_name)
else:
try:
return _do_import(plugin_module_name)
- except (ImportError, ModuleNotFoundError):
+ except ImportError:
log.exception("failed to import %s", plugin_module_name)