laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37680?usp=email )
Change subject: pySim.tlv: Fix from_dict of nested TLVs ......................................................................
pySim.tlv: Fix from_dict of nested TLVs
The existing logic is wrong. How we call from_dict() doesn't differ if a member IE itself contains a nested collection: We always must pass a single-entry dict with the snak-case name of the class to from_dict().
Change-Id: Ic1f9db45db75b887227c2e20785198814cbab0f5 Fixes: OS#6453 --- M pySim/tlv.py 1 file changed, 15 insertions(+), 6 deletions(-)
Approvals: fixeria: Looks good to me, but someone else must approve; Verified Jenkins Builder: Verified laforge: Looks good to me, approved
diff --git a/pySim/tlv.py b/pySim/tlv.py index 8180fd1..bd3c901 100644 --- a/pySim/tlv.py +++ b/pySim/tlv.py @@ -495,12 +495,7 @@ # resolve the class for that name; create an instance of it cls = self.members_by_name[k] inst = cls() - if cls.nested_collection_cls: - # in case of collections, we want to pass the raw "value" portion to from_dict, - # as to_dict() below intentionally omits the collection-class-name as key - inst.from_dict(i[k]) - else: - inst.from_dict({k: i[k]}) + inst.from_dict({k: i[k]}) res.append(inst) else: raise ValueError('%s: Unknown TLV Class %s in %s; expected %s' %