forked from VimPlug/jedi
fixed the getattr/__getattr__ stuff
This commit is contained in:
@@ -258,16 +258,15 @@ class Evaluator(object):
|
|||||||
call.stmt.parent = loop
|
call.stmt.parent = loop
|
||||||
result += self.eval_statement(call.stmt)
|
result += self.eval_statement(call.stmt)
|
||||||
else:
|
else:
|
||||||
if isinstance(call, compiled.PyName):
|
if isinstance(call, pr.Lambda):
|
||||||
print call, call.parent
|
|
||||||
result.append(call.parent)
|
|
||||||
elif isinstance(call, pr.Lambda):
|
|
||||||
result.append(er.Function(self, call))
|
result.append(er.Function(self, call))
|
||||||
# With things like params, these can also be functions...
|
# With things like params, these can also be functions...
|
||||||
elif isinstance(call, pr.Base) and call.isinstance(
|
elif isinstance(call, pr.Base) and call.isinstance(
|
||||||
er.Function, er.Class, er.Instance, iterable.ArrayInstance):
|
er.Function, er.Class, er.Instance, iterable.ArrayInstance):
|
||||||
result.append(call)
|
result.append(call)
|
||||||
# The string tokens are just operations (+, -, etc.)
|
# The string tokens are just operations (+, -, etc.)
|
||||||
|
elif isinstance(call, compiled.PyObject):
|
||||||
|
result.append(call)
|
||||||
elif not isinstance(call, (str, unicode)):
|
elif not isinstance(call, (str, unicode)):
|
||||||
if isinstance(call, pr.Call) and str(call.name) == 'if':
|
if isinstance(call, pr.Call) and str(call.name) == 'if':
|
||||||
# Ternary operators.
|
# Ternary operators.
|
||||||
|
|||||||
@@ -91,9 +91,6 @@ class PyName(object):
|
|||||||
self._obj = obj
|
self._obj = obj
|
||||||
self._name = name
|
self._name = name
|
||||||
self.start_pos = 0, 0 # an illegal start_pos, to make sorting easy.
|
self.start_pos = 0, 0 # an illegal start_pos, to make sorting easy.
|
||||||
#if not type(name) is str:
|
|
||||||
# print obj, name
|
|
||||||
# raise NotImplementedError()
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<%s: (%s).%s>' % (type(self).__name__, repr(self._obj.obj), self._name)
|
return '<%s: (%s).%s>' % (type(self).__name__, repr(self._obj.obj), self._name)
|
||||||
@@ -223,7 +220,3 @@ magic_function_class = PyObject(type(load_module), parent=builtin)
|
|||||||
|
|
||||||
def create(obj):
|
def create(obj):
|
||||||
return PyObject(obj, builtin)
|
return PyObject(obj, builtin)
|
||||||
|
|
||||||
|
|
||||||
def name_from_string(string):
|
|
||||||
return PyName(create(string), string)
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class NameFinder(object):
|
|||||||
"""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 = compiled.name_from_string(self.name_str)
|
name = compiled.create(str(self.name_str))
|
||||||
with common.ignored(KeyError):
|
with common.ignored(KeyError):
|
||||||
result = inst.execute_subscope_by_name('__getattr__', [name])
|
result = inst.execute_subscope_by_name('__getattr__', [name])
|
||||||
if not result:
|
if not result:
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ def builtins_getattr(evaluator, obj, params):
|
|||||||
|
|
||||||
for name in names:
|
for name in names:
|
||||||
s = unicode, str
|
s = unicode, str
|
||||||
print name
|
|
||||||
if isinstance(name, compiled.PyObject) and isinstance(name.obj, s):
|
if isinstance(name, compiled.PyObject) and isinstance(name.obj, s):
|
||||||
stmts += evaluator.follow_path(iter([name.obj]), [obj], obj)
|
stmts += evaluator.follow_path(iter([name.obj]), [obj], obj)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ class Wrapper2():
|
|||||||
return getattr(Base(), name)
|
return getattr(Base(), name)
|
||||||
|
|
||||||
#? int()
|
#? int()
|
||||||
Wrapper(Base()).ret
|
Wrapper(Base()).ret(3)
|
||||||
|
|
||||||
#? int()
|
#? int()
|
||||||
Wrapper2(Base()).ret(3)
|
Wrapper2(Base()).ret(3)
|
||||||
|
|||||||
Reference in New Issue
Block a user