mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-31 01:04:20 +08:00
Don't try to pickle ellipsis
This commit is contained in:
@@ -93,7 +93,7 @@ class Context(BaseContext):
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if type(index) not in (float, int, str, unicode, slice, type(Ellipsis)):
|
||||
if type(index) not in (float, int, str, unicode, slice):
|
||||
# If the index is not clearly defined, we have to get all the
|
||||
# possiblities.
|
||||
if isinstance(self, AbstractIterable) and self.array_type == 'dict':
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
from jedi._compatibility import builtins as _builtins
|
||||
from jedi._compatibility import unicode
|
||||
from jedi.evaluate.compiled.context import CompiledObject, CompiledName, \
|
||||
CompiledObjectFilter, CompiledContextName, create_from_access_path, \
|
||||
create_from_name
|
||||
from jedi.evaluate.compiled import access
|
||||
|
||||
|
||||
def builtin_from_name(evaluator, string):
|
||||
@@ -15,7 +14,7 @@ def create_simple_object(evaluator, obj):
|
||||
Only allows creations of objects that are easily picklable across Python
|
||||
versions.
|
||||
"""
|
||||
assert isinstance(obj, (int, float, str, bytes, slice, complex, type(Ellipsis)))
|
||||
assert isinstance(obj, (int, float, str, bytes, unicode, slice, complex))
|
||||
return create_from_access_path(
|
||||
evaluator,
|
||||
evaluator.compiled_subprocess.create_simple_object(obj)
|
||||
|
||||
@@ -155,7 +155,7 @@ class AccessPath(object):
|
||||
|
||||
def create_access_path(evaluator, obj):
|
||||
access = create_access(evaluator, obj)
|
||||
return AccessPath(access._get_access_path_tuples())
|
||||
return AccessPath(access.get_access_path_tuples())
|
||||
|
||||
|
||||
class DirectObjectAccess(object):
|
||||
@@ -274,7 +274,7 @@ class DirectObjectAccess(object):
|
||||
return None
|
||||
|
||||
def get_safe_value(self):
|
||||
if type(self._obj) in (bool, bytes, float, int, str, unicode, slice, type(Ellipsis)):
|
||||
if type(self._obj) in (bool, bytes, float, int, str, unicode, slice):
|
||||
return self._obj
|
||||
raise ValueError("Object is type %s and not simple" % type(self._obj))
|
||||
|
||||
@@ -290,7 +290,7 @@ class DirectObjectAccess(object):
|
||||
# Everything else...
|
||||
return 'instance'
|
||||
|
||||
def _get_access_path_tuples(self):
|
||||
def get_access_path_tuples(self):
|
||||
return [
|
||||
(getattr(o, '__name__', None), create_access(self._evaluator, o))
|
||||
for o in self._get_objects_path()
|
||||
|
||||
@@ -188,7 +188,7 @@ class _CompiledSubprocess(_Subprocess):
|
||||
self._evaluator_deletion_queue.append(evaluator_id)
|
||||
|
||||
|
||||
class Listener():
|
||||
class Listener(object):
|
||||
def __init__(self):
|
||||
self._evaluators = {}
|
||||
# TODO refactor so we don't need to process anymore just handle
|
||||
@@ -263,9 +263,10 @@ class AccessHandle(object):
|
||||
self.id = state
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name in ('id', '_subprocess', 'access'):
|
||||
if name in ('id', 'access') or name.startswith('_'):
|
||||
raise AttributeError("Something went wrong with unpickling")
|
||||
|
||||
#print >> sys.stderr, name
|
||||
#print('getattr', name, file=sys.stderr)
|
||||
def compiled_method(*args, **kwargs):
|
||||
return self._subprocess.get_compiled_method_return(self.id, name, *args, **kwargs)
|
||||
|
||||
@@ -87,10 +87,6 @@ def test_tokenizer_with_string_literal_backslash():
|
||||
|
||||
|
||||
def test_ellipsis():
|
||||
def_, = jedi.Script(dedent("""\
|
||||
class Foo():
|
||||
def __getitem__(self, index):
|
||||
return index
|
||||
Foo()[...]""")).goto_definitions()
|
||||
def_, = jedi.Script('x=...;x').goto_definitions()
|
||||
|
||||
assert def_.name == 'ellipsis'
|
||||
|
||||
Reference in New Issue
Block a user