forked from VimPlug/jedi
Use sys.modules instead of __import__
The module should already have been imported at this point. Plus if the __module__ was wrong it won't just randomly import something.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import inspect
|
import inspect
|
||||||
import types
|
import types
|
||||||
|
import sys
|
||||||
import operator as op
|
import operator as op
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -282,8 +283,8 @@ class DirectObjectAccess(object):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
# TODO use sys.modules, __module__ can be faked.
|
# TODO use sys.modules, __module__ can be faked.
|
||||||
yield __import__(imp_plz)
|
yield sys.modules[imp_plz]
|
||||||
except ImportError:
|
except KeyError:
|
||||||
# __module__ can be something arbitrary that doesn't exist.
|
# __module__ can be something arbitrary that doesn't exist.
|
||||||
yield builtins
|
yield builtins
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user