forked from VimPlug/jedi
Make the new project API fully work in tests
This commit is contained in:
@@ -67,7 +67,6 @@ import parso
|
||||
|
||||
from jedi import debug
|
||||
from jedi import parser_utils
|
||||
from jedi.api.environment import get_default_environment
|
||||
from jedi.evaluate.utils import unite
|
||||
from jedi.evaluate import imports
|
||||
from jedi.evaluate import recursion
|
||||
@@ -85,10 +84,11 @@ from jedi.evaluate.syntax_tree import eval_trailer, eval_expr_stmt, \
|
||||
|
||||
|
||||
class Evaluator(object):
|
||||
def __init__(self, project, environment=None):
|
||||
def __init__(self, project, environment=None, script_path=None):
|
||||
if environment is None:
|
||||
environment = get_default_environment()
|
||||
environment = project.get_environment()
|
||||
self.environment = environment
|
||||
self.script_path = script_path
|
||||
self.compiled_subprocess = environment.get_evaluator_subprocess(self)
|
||||
self.grammar = environment.get_grammar()
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import subprocess
|
||||
import socket
|
||||
import errno
|
||||
import weakref
|
||||
import traceback
|
||||
from functools import partial
|
||||
|
||||
from jedi._compatibility import queue, is_py3, force_unicode, pickle_dump, pickle_load
|
||||
@@ -195,12 +196,15 @@ class _CompiledSubprocess(object):
|
||||
raise InternalError("The subprocess was killed. Maybe out of memory?")
|
||||
|
||||
try:
|
||||
is_exception, result = pickle_load(self._process.stdout)
|
||||
is_exception, traceback, result = pickle_load(self._process.stdout)
|
||||
except EOFError:
|
||||
self.kill()
|
||||
raise InternalError("The subprocess crashed.")
|
||||
|
||||
if is_exception:
|
||||
# Replace the attribute error message with a the traceback. It's
|
||||
# way more informative.
|
||||
result.args = (traceback,)
|
||||
raise result
|
||||
return result
|
||||
|
||||
@@ -270,11 +274,9 @@ class Listener(object):
|
||||
# here and just exit.
|
||||
exit(1)
|
||||
try:
|
||||
result = False, self._run(*payload)
|
||||
result = False, None, self._run(*payload)
|
||||
except Exception as e:
|
||||
#import traceback
|
||||
#print_to_stderr(traceback.format_exc())
|
||||
result = True, e
|
||||
result = True, traceback.format_exc(), e
|
||||
|
||||
pickle_dump(result, file=stdout)
|
||||
stdout.flush()
|
||||
|
||||
@@ -517,10 +517,11 @@ def get_modules_containing_name(evaluator, modules, name):
|
||||
with open(path, 'rb') as f:
|
||||
code = python_bytes_to_unicode(f.read(), errors='replace')
|
||||
if name in code:
|
||||
module = _load_module(evaluator, path, code)
|
||||
e_sys_path = evaluator.get_sys_path()
|
||||
module = _load_module(evaluator, path, code, sys_path=e_sys_path)
|
||||
|
||||
module_name = sys_path.dotted_path_in_sys_path(
|
||||
evaluator.get_sys_path(), path
|
||||
e_sys_path, path
|
||||
)
|
||||
if module_name is not None:
|
||||
add_module(evaluator, module_name, module)
|
||||
|
||||
Reference in New Issue
Block a user