From 3f25ba436c4023ad997f8f93d29690e23f016e5a Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 4 Dec 2017 00:21:12 +0100 Subject: [PATCH] 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. --- jedi/evaluate/compiled/access.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jedi/evaluate/compiled/access.py b/jedi/evaluate/compiled/access.py index a5f693fe..48fcf9d6 100644 --- a/jedi/evaluate/compiled/access.py +++ b/jedi/evaluate/compiled/access.py @@ -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