From 86f972cde1cc154a176c3614e289ab4d3303fedc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 23 Nov 2019 07:52:18 +0530 Subject: [PATCH] Handle not being able to decode plugin loading failure exceptions --- src/calibre/constants.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/constants.py b/src/calibre/constants.py index d84c315cc1..87851bd069 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -2,7 +2,7 @@ # vim:fileencoding=utf-8 # License: GPLv3 Copyright: 2015, Kovid Goyal from __future__ import print_function, unicode_literals -from polyglot.builtins import map, unicode_type, environ_item, hasenv, getenv +from polyglot.builtins import map, unicode_type, environ_item, hasenv, getenv, as_unicode, native_string_type import sys, locale, codecs, os, importlib, collections __appname__ = 'calibre' @@ -213,7 +213,10 @@ class Plugins(collections.Mapping): p = importlib.import_module(name) except Exception as err: p = None - plugin_err = unicode_type(err) + try: + plugin_err = unicode_type(err) + except Exception: + plugin_err = as_unicode(native_string_type(err), encoding=preferred_encoding, errors='replace') self._plugins[name] = p, plugin_err sys.path.remove(plugins_loc)