mirror of
https://github.com/ethereum/consensus-specs.git
synced 2026-02-02 16:45:01 -05:00
fix slicing, and support partial slice bounds
This commit is contained in:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user