forked from VimPlug/jedi
Fix issues with a recent refactoring
This commit is contained in:
@@ -360,7 +360,7 @@ class Evaluator(object):
|
||||
scope_node = parent_scope(node)
|
||||
return from_scope_node(scope_node, is_nested=True, node_is_object=node_is_object)
|
||||
|
||||
def parse_and_get_code(self, code, path, **kwargs):
|
||||
def parse_and_get_code(self, code=None, path=None, **kwargs):
|
||||
if self.allow_different_encoding:
|
||||
if code is None:
|
||||
with open(path, 'rb') as f:
|
||||
|
||||
@@ -379,7 +379,7 @@ def get_global_filters(evaluator, context, until_position, origin_scope):
|
||||
... def func():
|
||||
... y = None
|
||||
... '''))
|
||||
>>> module_node = script._get_module_node()
|
||||
>>> module_node = script._module_node
|
||||
>>> scope = next(module_node.iter_funcdefs())
|
||||
>>> scope
|
||||
<Function: func@3-5>
|
||||
|
||||
@@ -369,9 +369,20 @@ class Importer(object):
|
||||
else:
|
||||
module_path = get_init_path(module_path)
|
||||
elif module_file:
|
||||
if module_path.endswith(('.zip', '.egg')):
|
||||
# Unfortunately we are reading unicode here already, not byes.
|
||||
# It seems however hard to get bytes, because the zip importer
|
||||
# logic just unpacks the zip file and returns a file descriptor
|
||||
# that we cannot as easily access. Therefore we just read it as
|
||||
# a string.
|
||||
code = module_file.read()
|
||||
else:
|
||||
# Read the code with a binary file, because the binary file
|
||||
# might not be proper unicode. This is handled by the parser
|
||||
# wrapper.
|
||||
with open(module_path, 'rb') as f:
|
||||
code = f.read()
|
||||
module_file.close()
|
||||
with open(module_path, 'rb') as f:
|
||||
code = f.read()
|
||||
|
||||
if isinstance(module_path, ImplicitNSInfo):
|
||||
from jedi.evaluate.context.namespace import ImplicitNamespaceContext
|
||||
|
||||
Reference in New Issue
Block a user