1
0
forked from VimPlug/jedi

Fix: dicts lookups were not working in all cases.

This commit is contained in:
Dave Halter
2015-12-08 22:37:30 +01:00
parent bef5fca516
commit c9a5caa96e
4 changed files with 22 additions and 16 deletions

View File

@@ -225,14 +225,15 @@ class CompiledObject(Base):
for name in self._parse_function_doc()[1].split():
try:
bltn_obj = builtin_from_name(evaluator, name)
bltn_obj = getattr(_builtins, name)
except AttributeError:
continue
else:
if bltn_obj.obj is None:
if bltn_obj is None:
# We want to evaluate everything except None.
# TODO do we?
continue
bltn_obj = create(evaluator, bltn_obj)
for result in evaluator.execute(bltn_obj, params):
yield result
@@ -530,11 +531,4 @@ def create(evaluator, obj, parent=None, module=None):
faked.parent = parent
return faked
# TODO delete
#try:
#if parent == builtin and obj.__module__ in ('builtins', '__builtin__'):
#return builtin.get_by_name(obj.__name__)
#except AttributeError:
#pass
return CompiledObject(evaluator, obj, parent)

View File

@@ -65,6 +65,7 @@ def get_module(obj):
return builtins
else:
if imp_plz is None:
# Happens for example in `(_ for _ in []).send.__module__`.
return builtins
else:
return __import__(imp_plz)
@@ -77,7 +78,7 @@ def _faked(module, obj, name):
faked_mod = _load_faked_module(module)
if faked_mod is None:
return
return None
# Having the module as a `parser.representation.module`, we need to scan
# for methods.
@@ -95,12 +96,15 @@ def _faked(module, obj, name):
if cls is None:
return None
return search_scope(cls, obj.__name__)
else:
if obj == module:
return search_scope(faked_mod, name)
else:
cls = search_scope(faked_mod, obj.__name__)
try:
cls_name = obj.__name__
except AttributeError:
return None
cls = search_scope(faked_mod, cls_name)
if cls is None:
return None
return search_scope(cls, name)