From d81c2086c8866a74d7feb97b258e654545286d84 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 31 Jul 2024 23:14:54 +0200 Subject: [PATCH] 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 --- pySim/tlv.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pySim/tlv.py b/pySim/tlv.py index 8180fd12..bd3c901d 100644 --- a/pySim/tlv.py +++ b/pySim/tlv.py @@ -495,12 +495,7 @@ class TLV_IE_Collection(metaclass=TlvCollectionMeta): # 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' %