mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-31 01:04:20 +08:00
Exceptions now also work over the subprocess.
This commit is contained in:
@@ -51,6 +51,9 @@ class CheckAttribute(object):
|
||||
self.check_name = func.__name__[2:]
|
||||
|
||||
def __get__(self, instance, owner):
|
||||
if instance is None:
|
||||
return self
|
||||
|
||||
# This might raise an AttributeError. That's wanted.
|
||||
if self.check_name == '__iter__':
|
||||
# Python iterators are a bit strange, because there's no need for
|
||||
|
||||
@@ -98,7 +98,10 @@ class _Subprocess(object):
|
||||
data = evaluator_id, function, args, kwargs
|
||||
pickle.dump(data, self._process.stdin, protocol=_PICKLE_PROTOCOL)
|
||||
self._process.stdin.flush()
|
||||
return pickle.load(self._process.stdout)
|
||||
is_exception, result = pickle.load(self._process.stdout)
|
||||
if is_exception:
|
||||
raise result
|
||||
return result
|
||||
|
||||
def terminate(self):
|
||||
self._process.terminate()
|
||||
@@ -167,7 +170,10 @@ class Listener():
|
||||
# It looks like the parent process closed. Don't make a big fuss
|
||||
# here and just exit.
|
||||
exit(1)
|
||||
result = self._run(*payload)
|
||||
try:
|
||||
result = False, self._run(*payload)
|
||||
except Exception as e:
|
||||
result = True, e
|
||||
pickle.dump(result, stdout, protocol=_PICKLE_PROTOCOL)
|
||||
stdout.flush()
|
||||
|
||||
|
||||
@@ -36,3 +36,5 @@ def test_import_module(evaluator):
|
||||
compiled_obj = evaluator.compiled_subprocess.import_module(name='math')
|
||||
assert compiled_obj.py__bool__() is True
|
||||
assert compiled_obj.type == 'file_input'
|
||||
with pytest.raises(AttributeError):
|
||||
assert compiled_obj.py__mro__()
|
||||
|
||||
Reference in New Issue
Block a user