Fix an issue with dict lookups.

This commit is contained in:
Dave Halter
2015-12-05 20:40:41 +01:00
parent 3910d97b7e
commit 2008775370
2 changed files with 5 additions and 7 deletions

View File

@@ -272,12 +272,7 @@ class Array(IterableWrapper, ArrayMixin):
"""Here the index is an int/str. Raises IndexError/KeyError."""
if self.type == 'dict':
for key, values in self._items():
# Because we only want the key to be a string.
keys = self._evaluator.eval_element(key)
for k in keys:
if isinstance(k, compiled.CompiledObject) \
and index == k.obj:
if index == key:
for value in values:
return self._evaluator.eval_element(value)
raise KeyError('No key found in dictionary %s.' % self)
@@ -434,6 +429,9 @@ class MergedArray(_FakeArray):
def values(self):
return unite((a.values() for a in self._arrays))
def py__getitem__(self, index):
return unite(self.py__iter__())
def __iter__(self):
for array in self._arrays:
for a in array:

View File

@@ -120,7 +120,7 @@ def gen():
a, b = next(gen())
#? int()
a
#? str() float()
#? str()
b