From b196c6849b9e52a4f831226c7ee82423acd6983a Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 11 Dec 2017 20:55:34 +0100 Subject: [PATCH] Don't try to pickle ellipsis --- jedi/evaluate/base_context.py | 2 +- jedi/evaluate/compiled/__init__.py | 5 ++--- jedi/evaluate/compiled/access.py | 6 +++--- jedi/evaluate/compiled/subprocess/__init__.py | 5 +++-- test/test_parso_integration/test_basic.py | 6 +----- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/jedi/evaluate/base_context.py b/jedi/evaluate/base_context.py index 24df628a..6de9ec39 100644 --- a/jedi/evaluate/base_context.py +++ b/jedi/evaluate/base_context.py @@ -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': diff --git a/jedi/evaluate/compiled/__init__.py b/jedi/evaluate/compiled/__init__.py index eada702b..f34b42fe 100644 --- a/jedi/evaluate/compiled/__init__.py +++ b/jedi/evaluate/compiled/__init__.py @@ -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) diff --git a/jedi/evaluate/compiled/access.py b/jedi/evaluate/compiled/access.py index 82d143c9..36976b17 100644 --- a/jedi/evaluate/compiled/access.py +++ b/jedi/evaluate/compiled/access.py @@ -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() diff --git a/jedi/evaluate/compiled/subprocess/__init__.py b/jedi/evaluate/compiled/subprocess/__init__.py index cd76356c..27d7e262 100644 --- a/jedi/evaluate/compiled/subprocess/__init__.py +++ b/jedi/evaluate/compiled/subprocess/__init__.py @@ -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) diff --git a/test/test_parso_integration/test_basic.py b/test/test_parso_integration/test_basic.py index d6013baf..f191f90e 100644 --- a/test/test_parso_integration/test_basic.py +++ b/test/test_parso_integration/test_basic.py @@ -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'