mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 14:54:47 +08:00
Remove the last test failures.
This commit is contained in:
@@ -50,12 +50,16 @@ class _EvaluatorProcess(object):
|
|||||||
return self.get_access_handle(id_)
|
return self.get_access_handle(id_)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
access = DirectObjectAccess(self._evaluator_weakref(), obj)
|
access = DirectObjectAccess(self._evaluator_weakref(), obj)
|
||||||
handle = self._handles[id_] = AccessHandle(self, access, id_)
|
handle = AccessHandle(self, access, id_)
|
||||||
return handle
|
self.set_access_handle(handle)
|
||||||
|
return handle
|
||||||
|
|
||||||
def get_access_handle(self, id_):
|
def get_access_handle(self, id_):
|
||||||
return self._handles[id_]
|
return self._handles[id_]
|
||||||
|
|
||||||
|
def set_access_handle(self, handle):
|
||||||
|
self._handles[handle.id] = handle
|
||||||
|
|
||||||
|
|
||||||
class EvaluatorSameProcess(_EvaluatorProcess):
|
class EvaluatorSameProcess(_EvaluatorProcess):
|
||||||
"""
|
"""
|
||||||
@@ -84,7 +88,7 @@ class EvaluatorSubprocess(_EvaluatorProcess):
|
|||||||
func,
|
func,
|
||||||
args=args,
|
args=args,
|
||||||
kwargs=kwargs,
|
kwargs=kwargs,
|
||||||
unpickler=lambda stdout: _ModifiedMasterUnpickler(self, stdout).load()
|
unpickler=lambda stdout: _ModifiedUnpickler(self, stdout).load()
|
||||||
)
|
)
|
||||||
if isinstance(result, AccessHandle):
|
if isinstance(result, AccessHandle):
|
||||||
result.add_subprocess(self)
|
result.add_subprocess(self)
|
||||||
@@ -211,7 +215,7 @@ class Listener():
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
payload = pickle.load(file=stdin)
|
payload = pickle.load(stdin)
|
||||||
except EOFError:
|
except EOFError:
|
||||||
# It looks like the parent process closed. Don't make a big fuss
|
# It looks like the parent process closed. Don't make a big fuss
|
||||||
# here and just exit.
|
# here and just exit.
|
||||||
@@ -232,17 +236,20 @@ class _ModifiedUnpickler(pickle._Unpickler):
|
|||||||
super(_ModifiedUnpickler, self).__init__(*args, **kwargs)
|
super(_ModifiedUnpickler, self).__init__(*args, **kwargs)
|
||||||
self._subprocess = subprocess
|
self._subprocess = subprocess
|
||||||
|
|
||||||
def load_newobj(self):
|
def load_build(self):
|
||||||
super(_ModifiedUnpickler, self).load_newobj()
|
super(_ModifiedUnpickler, self).load_build()
|
||||||
tos = self.stack[-1]
|
tos = self.stack[-1]
|
||||||
if isinstance(tos, AccessHandle):
|
if isinstance(tos, AccessHandle):
|
||||||
self.stack[-1] = self.get_access_handle(tos)
|
self.stack[-1] = self.get_access_handle(tos)
|
||||||
dispatch[pickle.NEWOBJ[0]] = load_newobj
|
dispatch[pickle.BUILD[0]] = load_build
|
||||||
|
|
||||||
|
|
||||||
class _ModifiedMasterUnpickler(_ModifiedUnpickler):
|
|
||||||
def get_access_handle(self, access_handle):
|
def get_access_handle(self, access_handle):
|
||||||
access_handle.add_subprocess(self._subprocess)
|
try:
|
||||||
|
# Rewrite the access handle to one we're already having.
|
||||||
|
access_handle = self._subprocess.get_access_handle(access_handle.id)
|
||||||
|
except KeyError:
|
||||||
|
access_handle.add_subprocess(self._subprocess)
|
||||||
|
self._subprocess.set_access_handle(access_handle)
|
||||||
return access_handle
|
return access_handle
|
||||||
|
|
||||||
|
|
||||||
@@ -262,6 +269,9 @@ class AccessHandle(object):
|
|||||||
self.id = state
|
self.id = state
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
|
if name in ('id', '_subprocess', 'access'):
|
||||||
|
raise AttributeError("Something went wrong with unpickling")
|
||||||
|
|
||||||
#print('getattr', name, file=sys.stderr)
|
#print('getattr', name, file=sys.stderr)
|
||||||
def compiled_method(*args, **kwargs):
|
def compiled_method(*args, **kwargs):
|
||||||
return self._subprocess.get_compiled_method_return(self.id, name, *args, **kwargs)
|
return self._subprocess.get_compiled_method_return(self.id, name, *args, **kwargs)
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ def argument_clinic(string, want_obj=False, want_context=False, want_arguments=F
|
|||||||
try:
|
try:
|
||||||
lst = list(arguments.eval_argument_clinic(clinic_args))
|
lst = list(arguments.eval_argument_clinic(clinic_args))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return NO_CONTEXTS
|
result = NO_CONTEXTS
|
||||||
else:
|
else:
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
if want_context:
|
if want_context:
|
||||||
@@ -119,9 +119,10 @@ def argument_clinic(string, want_obj=False, want_context=False, want_arguments=F
|
|||||||
kwargs['obj'] = obj
|
kwargs['obj'] = obj
|
||||||
if want_arguments:
|
if want_arguments:
|
||||||
kwargs['arguments'] = arguments
|
kwargs['arguments'] = arguments
|
||||||
return func(evaluator, *lst, **kwargs)
|
result = func(evaluator, *lst, **kwargs)
|
||||||
finally:
|
finally:
|
||||||
debug.dbg('builtin end', color='MAGENTA')
|
debug.dbg('builtin end: %s', result, color='MAGENTA')
|
||||||
|
return result
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
return f
|
return f
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ def test_fake_loading(evaluator):
|
|||||||
|
|
||||||
|
|
||||||
def test_fake_docstr(evaluator):
|
def test_fake_docstr(evaluator):
|
||||||
next_ = interpreter._create(evaluator, next)
|
next_ = compiled.builtin_from_name(evaluator, 'next')
|
||||||
assert next_.py__doc__()
|
assert next_.py__doc__()
|
||||||
assert next_.tree_node is not None
|
assert next_.tree_node is not None
|
||||||
assert next_.py__doc__() == next.__doc__
|
assert next_.py__doc__() == next.__doc__
|
||||||
@@ -49,7 +49,9 @@ def test_doc(evaluator):
|
|||||||
Even CompiledObject docs always return empty docstrings - not None, that's
|
Even CompiledObject docs always return empty docstrings - not None, that's
|
||||||
just a Jedi API definition.
|
just a Jedi API definition.
|
||||||
"""
|
"""
|
||||||
obj = interpreter._create(evaluator, ''.__getnewargs__)
|
str_ = compiled.create_simple_object(evaluator, '')
|
||||||
|
# Equals `''.__getnewargs__`
|
||||||
|
obj = compiled.create_from_name(evaluator, str_, '__getnewargs__')
|
||||||
assert obj.py__doc__() == ''
|
assert obj.py__doc__() == ''
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user