forked from VimPlug/jedi
Fix a few more tests
This commit is contained in:
@@ -205,7 +205,12 @@ class CompiledObject(Context):
|
||||
)
|
||||
|
||||
def get_safe_value(self, default=_sentinel):
|
||||
return self.access.get_safe_value(default=default)
|
||||
try:
|
||||
return self.access.get_safe_value()
|
||||
except ValueError:
|
||||
if default == _sentinel:
|
||||
raise
|
||||
return default
|
||||
|
||||
def execute_operation(self, other, operator):
|
||||
return _create_from_access(
|
||||
@@ -565,8 +570,6 @@ def _create(evaluator, access, parent_context=None, faked=None):
|
||||
parent_context = create(evaluator, _builtins)
|
||||
return create(evaluator, access, parent_context)
|
||||
|
||||
if access._obj == str:
|
||||
print('OOOOOOOOOO', id(access), id(parent_context), id(faked))
|
||||
return CompiledObject(evaluator, access, parent_context, faked)
|
||||
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ def compiled_objects_cache(attribute_name):
|
||||
Caching the id has the advantage that an object doesn't need to be
|
||||
hashable.
|
||||
"""
|
||||
def wrapper(evaluator, obj):
|
||||
def wrapper(evaluator, obj, parent_context=None):
|
||||
cache = getattr(evaluator, attribute_name)
|
||||
# Do a very cheap form of caching here.
|
||||
key = id(obj)
|
||||
@@ -91,9 +91,13 @@ def compiled_objects_cache(attribute_name):
|
||||
cache[key]
|
||||
return cache[key][0]
|
||||
except KeyError:
|
||||
result = func(evaluator, obj)
|
||||
# TODO wuaaaarrghhhhhhhh
|
||||
if attribute_name == 'mixed_cache':
|
||||
result = func(evaluator, obj, parent_context)
|
||||
else:
|
||||
result = func(evaluator, obj)
|
||||
# Need to cache all of them, otherwise the id could be overwritten.
|
||||
cache[key] = result, obj
|
||||
cache[key] = result, obj, parent_context
|
||||
return result
|
||||
return wrapper
|
||||
|
||||
@@ -214,11 +218,10 @@ class DirectObjectAccess(object):
|
||||
raise
|
||||
return None
|
||||
|
||||
def get_safe_value(self, default=_sentinel):
|
||||
def get_safe_value(self):
|
||||
if type(self._obj) in (float, int, str, unicode, slice, type(Ellipsis)):
|
||||
return self._obj
|
||||
if default == _sentinel:
|
||||
raise ValueError
|
||||
raise ValueError
|
||||
|
||||
def get_api_type(self):
|
||||
obj = self._obj
|
||||
|
||||
@@ -109,7 +109,8 @@ def _load_module(evaluator, path, python_object):
|
||||
).get_root_node()
|
||||
python_module = inspect.getmodule(python_object)
|
||||
|
||||
evaluator.modules[python_module.__name__] = module
|
||||
# TODO we should actually make something like this possible.
|
||||
#evaluator.modules[python_module.__name__] = module
|
||||
return module
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user