CSN1: fix serialization with unset value

This commit is contained in:
p1-bmu 2021-11-09 10:50:43 +01:00
parent f68c8485ec
commit 315bd60b98
1 changed files with 10 additions and 9 deletions

View File

@ -929,15 +929,16 @@ class CSN1List(CSN1Obj):
def _to_pack_obj(self): def _to_pack_obj(self):
ret = [] ret = []
for i, val in enumerate(self._val): if self._val is not None:
Obj = self._list[i] for i, val in enumerate(self._val):
# transfer offset and value to Obj Obj = self._list[i]
obj_off, obj_val = Obj._off, Obj._val # transfer offset and value to Obj
Obj._off, Obj._val = self._off, val obj_off, obj_val = Obj._off, Obj._val
ret.extend( Obj._to_pack_csn() ) Obj._off, Obj._val = self._off, val
# restore offset and value ret.extend( Obj._to_pack_csn() )
self._off = Obj._off # restore offset and value
Obj._off, Obj._val = obj_off, obj_val self._off = Obj._off
Obj._off, Obj._val = obj_off, obj_val
return ret return ret
def clone(self): def clone(self):