Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed TLV decoder issue Fixed issue of the TLV decoder: When giving tlv_bytes = b"\0256\001\0255\001&\000\031\346x\2077\001$\002\001$\003\006$\004\000\030(\002\030\030\030\030", the following errors occur: Traceback (most recent call last): File "/home/chingtzuchen/exp/tlv2.py", line 743, in <module> out = reader.get() File "/home/chingtzuchen/exp/tlv2.py", line 459, in get self._get(self._tlv, self._decodings, out) File "/home/chingtzuchen/exp/tlv2.py", line 674, in _get self._decodeVal(tlv, decoding) File "/home/chingtzuchen/exp/tlv2.py", line 574, in _decodeVal self._get(tlv, decoding["Structure"], decoding["value"]) File "/home/chingtzuchen/exp/tlv2.py", line 674, in _get self._decodeVal(tlv, decoding) File "/home/chingtzuchen/exp/tlv2.py", line 578, in _decodeVal self._get(tlv, decoding["Array"], decoding["value"]) File "/home/chingtzuchen/exp/tlv2.py", line 674, in _get self._decodeVal(tlv, decoding) File "/home/chingtzuchen/exp/tlv2.py", line 574, in _decodeVal self._get(tlv, decoding["Structure"], decoding["value"]) File "/home/chingtzuchen/exp/tlv2.py", line 674, in _get self._decodeVal(tlv, decoding) File "/home/chingtzuchen/exp/tlv2.py", line 574, in _decodeVal self._get(tlv, decoding["Structure"], decoding["value"]) File "/home/chingtzuchen/exp/tlv2.py", line 674, in _get self._decodeVal(tlv, decoding) File "/home/chingtzuchen/exp/tlv2.py", line 582, in _decodeVal self._get(tlv, decoding["Path"], decoding["value"]) File "/home/chingtzuchen/exp/tlv2.py", line 685, in _get out[decoding["tag"]] = decoding["value"] IndexError: list assignment index out of range Added condition and made it more clean to fix the issue, after this fix the bytes can be decoded: {'Any': {1: [{1: {'Any': 2272847385, 1: [1, 6, 0], 2: False}}]}} * Update __init__.py * Add unit test case Add unit test case for structure TLV bytes input Test result: ``` $ python test_tlv.py ..... ---------------------------------------------------------------------- Ran 5 tests in 0.000s OK ``` * Update test_tlv.py Update style
- Loading branch information