Skip to content

Commit d3d92a7

Browse files
committed
Merge pull request #2838 from goanpeca/fix/error-check-on-plugin-load
Import spyplugins only if there's a valid spec/module
2 parents ba3a515 + fd66ce9 commit d3d92a7

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

Diff for: spyderlib/otherplugins.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -63,28 +63,31 @@ def _import_plugin(name, base_namespace, plugin_namespace, namespace_path,
6363
return
6464
try:
6565
# First add a mock module with the LOCALEPATH attribute so that the
66-
# helper method can fin the locale on import
66+
# helper method can find the locale on import
6767
mock = _ModuleMock()
6868
mock.LOCALEPATH = osp.join(namespace_path, name, 'locale')
6969
sys.modules[module_name] = mock
70-
70+
module = None
7171
if PY33:
7272
loader = importlib.machinery.PathFinder.find_module(
7373
name, [namespace_path])
74-
module = loader.load_module(name)
74+
if loader:
75+
module = loader.load_module(name)
7576
elif PY3:
7677
spec = importlib.machinery.PathFinder.find_spec(name,
7778
[namespace_path])
78-
module = spec.loader.load_module(name)
79+
if spec:
80+
module = spec.loader.load_module(name)
7981
else:
8082
info = imp.find_module(name, [namespace_path])
81-
module = imp.load_module(module_name, *info)
83+
if info:
84+
module = imp.load_module(module_name, *info)
8285

8386
# Then restore the actual loaded module instead of the mock
84-
sys.modules[module_name] = module
85-
86-
modlist.append(module)
87-
modnames.append(module_name)
87+
if module:
88+
sys.modules[module_name] = module
89+
modlist.append(module)
90+
modnames.append(module_name)
8891
except Exception:
8992
sys.stderr.write("ERROR: 3rd party plugin import failed for "
9093
"`{0}`\n".format(module_name))

0 commit comments

Comments
 (0)