1
0
forked from VimPlug/jedi

Merge branch 'master' of github.com:davidhalter/jedi

This commit is contained in:
Dave Halter
2020-08-04 18:29:26 +02:00
2 changed files with 10 additions and 4 deletions
+9 -3
View File
@@ -1,5 +1,6 @@
import inspect import inspect
import types import types
import traceback
import sys import sys
import operator as op import operator as op
from collections import namedtuple from collections import namedtuple
@@ -117,13 +118,18 @@ def load_module(inference_state, dotted_name, sys_path):
__import__(dotted_name) __import__(dotted_name)
except ImportError: except ImportError:
# If a module is "corrupt" or not really a Python module or whatever. # If a module is "corrupt" or not really a Python module or whatever.
print('Module %s not importable in path %s.' % (dotted_name, sys_path), file=sys.stderr) warnings.warn(
"Module %s not importable in path %s." % (dotted_name, sys_path),
UserWarning,
stacklevel=2,
)
return None return None
except Exception: except Exception:
# Since __import__ pretty much makes code execution possible, just # Since __import__ pretty much makes code execution possible, just
# catch any error here and print it. # catch any error here and print it.
import traceback warnings.warn(
print("Cannot import:\n%s" % traceback.format_exc(), file=sys.stderr) "Cannot import:\n%s" % traceback.format_exc(), UserWarning, stacklevel=2
)
return None return None
finally: finally:
sys.path = temp sys.path = temp