1
0
forked from VimPlug/jedi

Fix: the parent setting of deep_ast_copy worked the wrong way.

This commit is contained in:
Dave Halter
2016-01-07 18:52:06 +01:00
parent 06cb82830a
commit 379eb440cd
4 changed files with 12 additions and 15 deletions

View File

@@ -266,7 +266,7 @@ class Evaluator(object):
while parent is not None:
parent = parent.parent
predefined_if_name_dict = self.predefined_if_name_dict_dict.get(parent)
if predefined_if_name_dict:
if predefined_if_name_dict is not None:
return self._eval_element_not_cached(element)
return self._eval_element_cached(element)

View File

@@ -55,19 +55,14 @@ def deep_ast_copy(obj, parent=None, new_elements=None):
new_names_dict[string] = [new_elements[n] for n in names]
return new_obj
if obj.type == 'name':
if isinstance(obj, tree.BaseNode):
new_obj = copy_node(obj)
else:
# Special case of a Name object.
new_elements[obj] = new_obj = copy.copy(obj)
if parent is not None:
new_obj.parent = parent
elif isinstance(obj, tree.BaseNode):
new_obj = copy_node(obj)
if parent is not None:
for child in new_obj.children:
if isinstance(child, (tree.Name, tree.BaseNode)):
child.parent = parent
else: # String literals and so on.
new_obj = obj # Good enough, don't need to copy anything.
if parent is not None:
new_obj.parent = parent
return new_obj

View File

@@ -38,9 +38,9 @@ class IterableWrapper(tree.Base):
@memoize_default()
def _get_names_dict(self, names_dict):
builtin_methods = {}
for cls in type(self).mro():
for cls in reversed(type(self).mro()):
try:
builtin_methods = dict(builtin_methods, **cls.builtin_methods)
builtin_methods.update(cls.builtin_methods)
except AttributeError:
pass

View File

@@ -630,7 +630,9 @@ class FunctionExecution(Executed):
def __init__(self, evaluator, base, *args, **kwargs):
super(FunctionExecution, self).__init__(evaluator, base, *args, **kwargs)
self._copy_dict = {}
new_func = helpers.deep_ast_copy(base.base_func, self, self._copy_dict)
new_func = helpers.deep_ast_copy(base.base_func, new_elements=self._copy_dict)
for child in new_func.children:
child.parent = self
self.children = new_func.children
self.names_dict = new_func.names_dict