1
0
forked from VimPlug/jedi

use __import__ instead of exec_function (should have done that a long time ago)

This commit is contained in:
Dave Halter
2014-01-13 14:01:03 +01:00
parent 1c1349162c
commit 0c98c05cd3

View File

@@ -6,7 +6,7 @@ import re
import sys import sys
import os import os
from jedi._compatibility import builtins as _builtins, exec_function from jedi._compatibility import builtins as _builtins
from jedi import debug from jedi import debug
from jedi.parser.representation import Base from jedi.parser.representation import Base
from jedi.cache import underscore_memoization from jedi.cache import underscore_memoization
@@ -160,8 +160,8 @@ def load_module(path, name):
# sometimes there are endings like `_sqlite3.cpython-32mu` # sometimes there are endings like `_sqlite3.cpython-32mu`
name = re.sub(r'\..*', '', name) name = re.sub(r'\..*', '', name)
if path:
dot_path = [] dot_path = []
if path:
p = path p = path
# if path is not in sys.path, we need to make a well defined import # if path is not in sys.path, we need to make a well defined import
# like `from numpy.core import umath.` # like `from numpy.core import umath.`
@@ -179,10 +179,8 @@ def load_module(path, name):
sys_path.insert(0, path) sys_path.insert(0, path)
temp, sys.path = sys.path, sys_path temp, sys.path = sys.path, sys_path
content = {}
try: try:
exec_function('import %s as module' % name, content) module = __import__(name, {}, {}, dot_path[:-1])
module = content['module']
except AttributeError: except AttributeError:
# use sys.modules, because you cannot access some modules # use sys.modules, because you cannot access some modules
# directly. -> github issue #59 # directly. -> github issue #59