P1sec / pycrate

A Python library to ease the development of encoders and decoders for various protocols and file formats; contains ASN.1 and CSN.1 compilers.
GNU Lesser General Public License v2.1
381 stars 132 forks source link

Self._ext 'NoneType' object is not iterable #185

Closed samuel-rangel closed 2 years ago

samuel-rangel commented 2 years ago

I'm trying to encode in ber some telco data with my own defined asn1 structure. The compiler doesn't throw any error, I can use the created class and set value to my object with set_value() method, I can even view the data in the object with the to_asn1() method, but when I try to encode it with the to_ber() method it throws me an error. File "C:\Users\samue\AppData\Local\Programs\Python\Python310\lib\site-packages\pycrate-0.5.4-py3.10.egg\pycrate_asn1rt\asnobj_construct.py", line 2587, in _encode_ber_cont for ident in self._ext: TypeError: 'NoneType' object is not iterable Clearly ._ext field is None, but for what I read in the docs it is optional, and actually I've been able to encode other structures that are less complex that also had ._ext field None. My structure definition and some dummy data sample is attached VoLTE.zip

p1-bmu commented 2 years ago

SET is rarely used in ASN.1, so there may be a missing check lying in the runtime for years. In order to fix this, I need however to understand exactly what happens. I could compile your VoLTE.asn file, could you please tell me how to reproduce your issue exactly ?

samuel-rangel commented 2 years ago

Thanks for replying! Sure, here is a snippet that I'm using for testing test_VoLTE_encode.zip

p1-bmu commented 2 years ago

Fixed with last commit f0f3e47392e743591b75e159864c436738b1d430 Thanks for the report.