Fix some minor errors

This commit is contained in:
Dave Halter
2019-06-20 09:53:40 +02:00
parent b85c0db72e
commit 907fdaa153
2 changed files with 29 additions and 1 deletions

View File

@@ -276,6 +276,8 @@ class DictComprehension(ComprehensionMixin, Sequence):
for keys, values in self._iterate(): for keys, values in self._iterate():
for k in keys: for k in keys:
if isinstance(k, compiled.CompiledObject): if isinstance(k, compiled.CompiledObject):
# Be careful in the future if refactoring, index could be a
# slice.
if k.get_safe_value(default=object()) == index: if k.get_safe_value(default=object()) == index:
return values return values
raise SimpleGetItemNotFound() raise SimpleGetItemNotFound()
@@ -501,6 +503,9 @@ class FakeSequence(_FakeArray):
self._lazy_context_list = lazy_context_list self._lazy_context_list = lazy_context_list
def py__simple_getitem__(self, index): def py__simple_getitem__(self, index):
if isinstance(index, slice):
return ContextSet([self])
with reraise_getitem_errors(IndexError, TypeError): with reraise_getitem_errors(IndexError, TypeError):
lazy_context = self._lazy_context_list[index] lazy_context = self._lazy_context_list[index]
return lazy_context.infer() return lazy_context.infer()
@@ -540,7 +545,7 @@ class FakeDict(_DictMixin, _FakeArray):
except KeyError: except KeyError:
pass pass
with reraise_getitem_errors(KeyError): with reraise_getitem_errors(KeyError, TypeError):
lazy_context = self._dct[index] lazy_context = self._dct[index]
return lazy_context.infer() return lazy_context.infer()

View File

@@ -12,3 +12,26 @@ def asdfy():
xorz = getattr(asdfy()(), 'asdf') xorz = getattr(asdfy()(), 'asdf')
#? time #? time
xorz xorz
def args_returner(*args):
return args
#? tuple()
args_returner(1)[:]
#? int()
args_returner(1)[:][0]
def kwargs_returner(**kwargs):
return kwargs
# TODO This is not really correct, needs correction probably at some point, but
# at least it doesn't raise an error.
#? int()
kwargs_returner(a=1)[:]
#?
kwargs_returner(b=1)[:][0]