From 48d4c73f88bd61fdece0f7789fefe74bcff270d7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 26 Mar 2019 07:57:37 +0530 Subject: [PATCH] py3: Fix load_plugin() not handling load failures --- src/calibre/constants.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calibre/constants.py b/src/calibre/constants.py index cff793cd1c..e5781fe5b3 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -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):