1
0
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:
Dave Halter
2017-12-04 00:21:12 +01:00
parent 85abc55e89
commit 3f25ba436c

View File

@@ -1,5 +1,6 @@
import inspect
import types
import sys
import operator as op
from collections import namedtuple
@@ -282,8 +283,8 @@ class DirectObjectAccess(object):
else:
try:
# TODO use sys.modules, __module__ can be faked.
yield __import__(imp_plz)
except ImportError:
yield sys.modules[imp_plz]
except KeyError:
# __module__ can be something arbitrary that doesn't exist.
yield builtins