From b4ef672f87cb3d3afbd0a7244feabbb3b7158258 Mon Sep 17 00:00:00 2001 From: protolambda Date: Thu, 20 Jun 2019 21:12:46 +0200 Subject: [PATCH] deal with deepcopy modifying vector length from 0 to full length during copy --- test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py b/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py index 55acde44b..39fed9ac8 100644 --- a/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py +++ b/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py @@ -349,7 +349,12 @@ class Vector(BaseList): return cls.elem_type.is_fixed_size() def append(self, v): - raise Exception("cannot modify vector length") + # Deep-copy and other utils like to change the internals during work. + # Only complain if we had the right size. + if len(self) == self.__class__.length: + raise Exception("cannot modify vector length") + else: + super().append(v) def pop(self, *args): raise Exception("cannot modify vector length")