1
0
forked from VimPlug/jedi

Fix side effect issues with predefined names and lazy contexts.

This commit is contained in:
Dave Halter
2016-11-26 10:16:26 +01:00
parent fe54285311
commit 2161be2dcb
3 changed files with 14 additions and 3 deletions

View File

@@ -99,9 +99,17 @@ class LazyTreeContext(AbstractLazyContext):
def __init__(self, context, node):
super(LazyTreeContext, self).__init__(node)
self._context = context
# We need to save the predefined names. It's an unfortunate side effect
# that needs to be tracked otherwise results will be wrong.
self._predefined_names = dict(context.predefined_names)
def infer(self):
return self._context.eval_node(self.data)
old, self._context.predefined_names = \
self._context.predefined_names, self._predefined_names
try:
return self._context.eval_node(self.data)
finally:
self._context.predefined_names = old
def get_merged_lazy_context(lazy_contexts):