Attention is currently required from: fixeria, neels.
dexter has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/42662?usp=email )
Change subject: ts_51_011/EF.SMSP: fix handling of 'alpha_id' field ......................................................................
Patch Set 5:
(2 comments)
Patchset:
PS5: This should fix the problem with EF.SMSP. Please also have a look at the patch before this one.
File pySim/ts_51_011.py:
https://gerrit.osmocom.org/c/pysim/+/42662/comment/49808e36_8244a436?usp=ema... : PS5, Line 344: self._construct = Struct('alpha_id'/GsmOrUcs2Adapter(Rpad(Bytes(this._.total_len-28))), If we leave out the COptional, we make the parser more sensitive to broken file contents (see also the patch before this one. This were the bugs that were caught by the tests when I pushed this patch.
The reason why the parser gets more sensitive towards invalid input is the following: See: https://construct.readthedocs.io/en/latest/misc.html#conditional "Attempts to parse or build the subconstruct. If it fails during parsing, returns a None. If it fails during building, it puts nothing into the stream."
In my opinion the parser should reject invalid input and not try to make sense of some broken input. That is why I prefer to remove the COptional from the construct definition.
YFI: When the alpha_id is not present, we get the following results during decode: With COptional: alpha_id : 'null' Without COptional: alpha_id : ''