1
0
forked from VimPlug/jedi

fix some descriptor methods

This commit is contained in:
David Halter
2013-02-11 01:08:45 +01:00
parent cae38ed3d7
commit f423de1956
2 changed files with 15 additions and 7 deletions

View File

@@ -416,10 +416,8 @@ def check_getattr(inst, name_str):
# str is important to lose the NamePart! # str is important to lose the NamePart!
module = builtin.Builtin.scope module = builtin.Builtin.scope
name = pr.Call(module, str(name_str), pr.Call.STRING, (0, 0), inst) 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__', [stmt]) result = inst.execute_subscope_by_name('__getattr__', [name])
except KeyError: except KeyError:
pass pass
if not result: if not result:
@@ -428,7 +426,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__', [stmt]) result = inst.execute_subscope_by_name('__getattribute__', [name])
except KeyError: except KeyError:
pass pass
return result return result

View File

@@ -298,9 +298,9 @@ class Class(use_metaclass(cache.CachedMetaClass, pr.Base)):
return self.base.name return self.base.name
def __getattr__(self, name): def __getattr__(self, name):
if name not in ['start_pos', 'end_pos', 'parent', 'subscopes', if name not in ['start_pos', 'end_pos', 'parent', 'asserts', 'docstr',
'get_imports', 'get_parent_until', 'docstr', 'asserts']: 'get_imports', 'get_parent_until', 'get_code', 'subscopes']:
raise AttributeError("Don't touch this (%s)!" % name) raise AttributeError("Don't touch this: %s of %s !" % (name, self))
return getattr(self.base, name) return getattr(self.base, name)
def __repr__(self): def __repr__(self):
@@ -630,6 +630,16 @@ 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):
if stmt is None:
yield None, None
continue
old = stmt
# generate a statement if it's not already one.
module = builtin.Builtin.scope
stmt = pr.Statement(module, 'XXX code', [], [], [], [], (0, 0), None)
stmt._commands = [old]
# *args # *args
if 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:])