More fixes, because of CompiledObject modifications

This commit is contained in:
Dave Halter
2018-09-17 02:40:34 +02:00
parent eb9a852443
commit cc3b08fd1b
2 changed files with 10 additions and 5 deletions

View File

@@ -20,7 +20,8 @@ class CompiledValue(ContextWrapper):
self._compiled_obj = compiled_obj self._compiled_obj = compiled_obj
def __getattribute__(self, name): def __getattribute__(self, name):
if name in ('get_safe_value', 'execute_operation', 'access_handle'): if name in ('get_safe_value', 'execute_operation', 'access_handle',
'negate'):
return getattr(self._compiled_obj, name) return getattr(self._compiled_obj, name)
return super(CompiledValue, self).__getattribute__(name) return super(CompiledValue, self).__getattribute__(name)
@@ -33,7 +34,7 @@ def create_simple_object(evaluator, obj):
Only allows creations of objects that are easily picklable across Python Only allows creations of objects that are easily picklable across Python
versions. versions.
""" """
assert type(obj) in (int, float, str, bytes, unicode, slice, complex) assert type(obj) in (int, float, str, bytes, unicode, slice, complex, bool), obj
compiled_obj = create_from_access_path( compiled_obj = create_from_access_path(
evaluator, evaluator,
evaluator.compiled_subprocess.create_simple_object(obj) evaluator.compiled_subprocess.create_simple_object(obj)

View File

@@ -295,9 +295,13 @@ class SequenceLiteralContext(Sequence):
compiled_obj_index = compiled.create_simple_object(self.evaluator, index) compiled_obj_index = compiled.create_simple_object(self.evaluator, index)
for key, value in self.get_tree_entries(): for key, value in self.get_tree_entries():
for k in self._defining_context.eval_node(key): for k in self._defining_context.eval_node(key):
if isinstance(k, compiled.CompiledObject) \ try:
and k.execute_operation(compiled_obj_index, u'==').get_safe_value(): method = k.execute_operation
return self._defining_context.eval_node(value) except AttributeError:
pass
else:
if method(compiled_obj_index, u'==').get_safe_value():
return self._defining_context.eval_node(value)
raise SimpleGetItemNotFound('No key found in dictionary %s.' % self) raise SimpleGetItemNotFound('No key found in dictionary %s.' % self)
if isinstance(index, slice): if isinstance(index, slice):