1
0
forked from VimPlug/jedi

Merge with master again

Some bugs were still present in master
This commit is contained in:
Dave Halter
2018-01-20 21:45:55 +01:00
6 changed files with 19 additions and 6 deletions

View File

@@ -369,7 +369,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:

View File

@@ -49,7 +49,20 @@ def get_module_info(evaluator, sys_path=None, full_name=None, **kwargs):
else:
module_path = _get_init_path(module_path)
elif module_file:
code = module_file.read()
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()
return code, cast_path(module_path), is_pkg

View File

@@ -490,7 +490,7 @@ def tree_name_to_contexts(evaluator, context, tree_name):
exceptions = context.eval_node(tree_name.get_previous_sibling().get_previous_sibling())
types = exceptions.execute_evaluated()
else:
raise ValueError("Should not happen.")
raise ValueError("Should not happen. type: %s" % typ)
return types