deal with deepcopy modifying vector length from 0 to full length during copy

This commit is contained in:
protolambda 2019-06-20 21:12:46 +02:00
parent 8bd204827b
commit b4ef672f87
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
1 changed files with 6 additions and 1 deletions

View File

@ -349,7 +349,12 @@ class Vector(BaseList):
return cls.elem_type.is_fixed_size() return cls.elem_type.is_fixed_size()
def append(self, v): 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): def pop(self, *args):
raise Exception("cannot modify vector length") raise Exception("cannot modify vector length")