1
0
forked from VimPlug/jedi

fixed the getattr/__getattr__ stuff

This commit is contained in:
Dave Halter
2014-01-10 15:14:55 +01:00
parent f868668f0e
commit 14c9ed88ca
5 changed files with 5 additions and 14 deletions

View File

@@ -258,16 +258,15 @@ class Evaluator(object):
call.stmt.parent = loop
result += self.eval_statement(call.stmt)
else:
if isinstance(call, compiled.PyName):
print call, call.parent
result.append(call.parent)
elif isinstance(call, pr.Lambda):
if isinstance(call, pr.Lambda):
result.append(er.Function(self, call))
# With things like params, these can also be functions...
elif isinstance(call, pr.Base) and call.isinstance(
er.Function, er.Class, er.Instance, iterable.ArrayInstance):
result.append(call)
# The string tokens are just operations (+, -, etc.)
elif isinstance(call, compiled.PyObject):
result.append(call)
elif not isinstance(call, (str, unicode)):
if isinstance(call, pr.Call) and str(call.name) == 'if':
# Ternary operators.

View File

@@ -91,9 +91,6 @@ class PyName(object):
self._obj = obj
self._name = name
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):
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):
return PyObject(obj, builtin)
def name_from_string(string):
return PyName(create(string), string)

View File

@@ -84,7 +84,7 @@ class NameFinder(object):
"""Checks for both __getattr__ and __getattribute__ methods"""
result = []
# 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):
result = inst.execute_subscope_by_name('__getattr__', [name])
if not result:

View File

@@ -51,7 +51,6 @@ def builtins_getattr(evaluator, obj, params):
for name in names:
s = unicode, str
print name
if isinstance(name, compiled.PyObject) and isinstance(name.obj, s):
stmts += evaluator.follow_path(iter([name.obj]), [obj], obj)
else:

View File

@@ -339,7 +339,7 @@ class Wrapper2():
return getattr(Base(), name)
#? int()
Wrapper(Base()).ret
Wrapper(Base()).ret(3)
#? int()
Wrapper2(Base()).ret(3)