tplugins: on some systems plugins with relative imports failed to load - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 811169da4b9a31388cc1d9e8e2cac738f14eded9 DIR parent 29ce50a30566d1c69c99896c355df9084a3b3cbd HTML Author: SomberNight <somber.night@protonmail.com> Date: Wed, 12 Jun 2019 20:07:36 +0200 plugins: on some systems plugins with relative imports failed to load tthis caused electrum to fail to start potentially only older python 3.6.x are affected fixes #5421 Diffstat: M electrum/plugin.py | 4 ++++ 1 file changed, 4 insertions(+), 0 deletions(-) --- DIR diff --git a/electrum/plugin.py b/electrum/plugin.py t@@ -27,6 +27,7 @@ import pkgutil import importlib.util import time import threading +import sys from typing import NamedTuple, Any, Union, TYPE_CHECKING, Optional from .i18n import _ t@@ -73,6 +74,9 @@ class Plugins(DaemonThread): raise Exception(f"Error pre-loading {full_name}: no spec") try: module = importlib.util.module_from_spec(spec) + # sys.modules needs to be modified for relative imports to work + # see https://stackoverflow.com/a/50395128 + sys.modules[spec.name] = module spec.loader.exec_module(module) except Exception as e: raise Exception(f"Error pre-loading {full_name}: {repr(e)}") from e