forked from VimPlug/jedi
fix getattr/__getattr*__
This commit is contained in:
@@ -414,9 +414,12 @@ def check_getattr(inst, name_str):
|
|||||||
"""Checks for both __getattr__ and __getattribute__ methods"""
|
"""Checks for both __getattr__ and __getattribute__ methods"""
|
||||||
result = []
|
result = []
|
||||||
# str is important to lose the NamePart!
|
# str is important to lose the NamePart!
|
||||||
name = pr.Call(str(name_str), pr.Call.STRING, (0, 0), inst)
|
module = builtin.Builtin.scope
|
||||||
|
name = pr.Call(module, str(name_str), pr.Call.STRING, (0, 0), inst)
|
||||||
|
stmt = pr.Statement(module, 'XXX code', [], [], [], [], (0, 0), None)
|
||||||
|
stmt._commands = [name]
|
||||||
try:
|
try:
|
||||||
result = inst.execute_subscope_by_name('__getattr__', [name])
|
result = inst.execute_subscope_by_name('__getattr__', [stmt])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
if not result:
|
if not result:
|
||||||
@@ -425,7 +428,7 @@ def check_getattr(inst, name_str):
|
|||||||
# could be practical and the jedi would return wrong types. If
|
# could be practical and the jedi would return wrong types. If
|
||||||
# you ever have something, let me know!
|
# you ever have something, let me know!
|
||||||
try:
|
try:
|
||||||
result = inst.execute_subscope_by_name('__getattribute__', [name])
|
result = inst.execute_subscope_by_name('__getattribute__', [stmt])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -423,8 +423,10 @@ class Execution(Executable):
|
|||||||
debug.warning('getattr called without instance')
|
debug.warning('getattr called without instance')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for name in names:
|
for arr_name in names:
|
||||||
key = name.var_args.get_only_subelement()
|
if len(arr_name.var_args) != 1:
|
||||||
|
debug.warning('jedi getattr is too simple')
|
||||||
|
key = arr_name.var_args[0]
|
||||||
stmts += evaluate.follow_path(iter([key]), obj,
|
stmts += evaluate.follow_path(iter([key]), obj,
|
||||||
self.base)
|
self.base)
|
||||||
return stmts
|
return stmts
|
||||||
@@ -507,7 +509,7 @@ class Execution(Executable):
|
|||||||
start_pos = self.var_args.start_pos
|
start_pos = self.var_args.start_pos
|
||||||
else:
|
else:
|
||||||
parent = self.base
|
parent = self.base
|
||||||
start_pos = None
|
start_pos = 0, 0
|
||||||
|
|
||||||
new_param = copy.copy(param)
|
new_param = copy.copy(param)
|
||||||
new_param.is_generated = True
|
new_param.is_generated = True
|
||||||
@@ -628,10 +630,8 @@ class Execution(Executable):
|
|||||||
def iterate():
|
def iterate():
|
||||||
# `var_args` is typically an Array, and not a list.
|
# `var_args` is typically an Array, and not a list.
|
||||||
for stmt in self.var_args:
|
for stmt in self.var_args:
|
||||||
if not isinstance(stmt, pr.Statement):
|
|
||||||
yield None, stmt
|
|
||||||
# *args
|
# *args
|
||||||
elif stmt.get_commands()[0] == '*':
|
if stmt.get_commands()[0] == '*':
|
||||||
arrays = evaluate.follow_call_list(stmt.get_commands()[1:])
|
arrays = evaluate.follow_call_list(stmt.get_commands()[1:])
|
||||||
# *args must be some sort of an array, otherwise -> ignore
|
# *args must be some sort of an array, otherwise -> ignore
|
||||||
for array in arrays:
|
for array in arrays:
|
||||||
|
|||||||
Reference in New Issue
Block a user