From 5895380a45740d1a7e22666ab29a080cf01bbcec Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 21 Oct 2021 11:33:44 +0200 Subject: [PATCH] tlv: Fix recursive initialization from_dict() When calling from_dict() on a hierarchy of nested BER_TLV_IE, only the first/outer layer of TLV_IE_Collection would get its 'decoded' initialized correctly from the dict. Subsequent layers were not, as the 'decoded=' was passed as parameter during instance initialization. If we first instantiate the class and then call the from_dict() method, the recursive initialization down the full hierarchy works as expected. Change-Id: I795a33ed8dfa8454dc9079c189ab7b2ba64a3b72 --- pySim/tlv.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pySim/tlv.py b/pySim/tlv.py index 0dc746b3..e1e28525 100644 --- a/pySim/tlv.py +++ b/pySim/tlv.py @@ -373,7 +373,8 @@ class TLV_IE_Collection(metaclass=TlvCollectionMeta): for k in i.keys(): if k in self.members_by_name: cls = self.members_by_name[k] - inst = cls(decoded=i[k]) + inst = cls() + inst.from_dict(i[k]) res.append(inst) else: raise ValueError('%s: Unknown TLV Class %s in %s; expected %s' %