From 8f001f8045cc9cb0c411bdaa96a518add4f71bba Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 9 Feb 2020 09:53:06 +0100 Subject: [PATCH] Check spec.loader is not None when importing a plugin. --- src/plugin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugin.py b/src/plugin.py index 8821bbd4c..78abfb0fc 100644 --- a/src/plugin.py +++ b/src/plugin.py @@ -69,7 +69,10 @@ def loadPluginModule(name, ignoreDeprecation=False): if hasattr(importlib.util, 'module_from_spec'): # Python >= 3.5 spec = importlib.machinery.PathFinder.find_spec(name, pluginDirs) - if spec is None: + if spec is None or spec.loader is None: + # spec is None if 'name' can't be found; and + # spec.loader might be None in some rare occasions as well + # (eg. for namespace packages) assert ImportError(name) module = importlib.util.module_from_spec(spec) sys.modules[module.__name__] = module