fix slicing, and support partial slice bounds

This commit is contained in:
protolambda
2019-06-28 17:27:59 +02:00
parent 5ff13dd81a
commit 128bbbc665
2 changed files with 2 additions and 2 deletions

View File

@@ -325,7 +325,7 @@ class BaseList(list, Elements):
def __setitem__(self, k, v):
if type(k) == slice:
if k.start < 0 or k.stop > len(self):
if (k.start is not None and k.start < 0) or (k.stop is not None and k.stop > len(self)):
raise IndexError(f"cannot set item in type {self.__class__}"
f" at out of bounds slice {k} (to {v}, bound: {len(self)})")
super().__setitem__(k, [coerce_type_maybe(x, self.__class__.elem_type) for x in v])