py3: Fix load_plugin() not handling load failures

This commit is contained in:
Kovid Goyal 2019-03-26 07:57:37 +05:30
parent 1c846769db
commit 48d4c73f88
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -203,12 +203,13 @@ class Plugins(collections.Mapping):
del sys.modules[name]
except KeyError:
pass
plugin_err = u''
try:
p, err = importlib.import_module(name), ''
p = importlib.import_module(name)
except Exception as err:
p = None
err = str(err)
self._plugins[name] = (p, err)
plugin_err = unicode_type(err)
self._plugins[name] = p, plugin_err
sys.path.remove(sys.extensions_location)
def __iter__(self):