Skip to content

Commit

Permalink
Merge from 3.x: PR #7263
Browse files Browse the repository at this point in the history
Fixes #7259
  • Loading branch information
ccordoba12 committed Jun 6, 2018
2 parents 1e7f637 + 604d8ff commit 6d4958c
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions spyder/otherplugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,27 +103,20 @@ def _import_module_from_path(module_name, plugin_path):
Return None if no module is found.
"""
module = None
if PY2:
info = imp.find_module(module_name, [plugin_path])
if info:
module = imp.load_module(module_name, *info)
elif sys.version_info[0:2] <= (3, 3):
loader = importlib.machinery.PathFinder.find_module(
module_name,
[plugin_path])
if loader:
module = loader.load_module(module_name)
else: # Python 3.4+
spec = importlib.machinery.PathFinder.find_spec(
module_name,
[plugin_path])
if spec:
# Needed to prevent an error when 'spec.loader' is None
# See issue 6518
try:
try:
if PY2:
info = imp.find_module(module_name, [plugin_path])
if info:
module = imp.load_module(module_name, *info)
else: # Python 3.4+
spec = importlib.machinery.PathFinder.find_spec(
module_name,
[plugin_path])
if spec:
module = spec.loader.load_module(module_name)
except AttributeError:
module = None
except Exception:
pass

return module


Expand Down

0 comments on commit 6d4958c

Please sign in to comment.