{"id":24799,"library":"uttlv","title":"UTTLV - Python TLV (Tag-Length-Value) Library","description":"A Python library for encoding and decoding TLV (Tag-Length-Value) objects. Supports custom tag definitions, nested TLV structures, and iterator access. Current version 0.7.1, maintained on GitHub.","status":"active","version":"0.7.1","language":"python","source_language":"en","source_url":"https://github.com/ustropo/uttlv","tags":["tlv","encoding","decoding","tag-length-value","binary"],"install":[{"cmd":"pip install uttlv","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"","symbol":"Tlv","correct":"from uttlv import Tlv"}],"quickstart":{"code":"from uttlv import Tlv\n\ntlv = Tlv()\ntlv[0x01] = b'data'\nencoded = tlv.to_bytes()\nprint('Encoded:', encoded.hex())\n\ndecoded = Tlv()\ndecoded.from_bytes(encoded)\nassert decoded[0x01] == b'data'","lang":"python","description":"Create a TLV object, set a tag, encode to bytes, decode back."},"warnings":[{"fix":"Update constructor calls to use keyword arguments: Tlv(tag_len_sizes=...) if needed.","message":"In v0.7.0, the 'nested_tag_config_map' parameter was added to Tlv constructor, changing the signature. Code using positional arguments for 'tag_len_sizes' may break.","severity":"breaking","affected_versions":"<0.7.0"},{"fix":"Always use integer tag values, e.g., tlv[0x01] = b'...'.","message":"Tag values must be integers; assigning non-integer keys will raise TypeError.","severity":"gotcha","affected_versions":"all"},{"fix":"Convert hex string to bytes first: tlv.from_bytes(bytes.fromhex('010203'))","message":"When decoding, from_bytes() expects bytes, not hex string. Common mistake is passing a hex string directly.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure you have created a Tlv instance: tlv = Tlv() and use integer tags: tlv[0x01] = b'data'","cause":"Attempting to assign to a Tlv object that has not been initialized properly or using a non-integer tag.","error":"TypeError: 'Tlv' object does not support item assignment"},{"fix":"Define tag_len_sizes as a dict mapping tag ranges to (tag_bytes, length_bytes). Default is {0x00: (1,1)}. See docs for custom sizes.","cause":"The tag_len_sizes parameter is not correctly specified or the encoded TLV uses lengths outside the defined sizes.","error":"ValueError: Invalid tag length size"},{"fix":"Use the same Tlv instance or configure the decoder with expected tags via tag_len_sizes or nested_tag_config_map.","cause":"Decoding TLV with tags not present in the current Tlv instance's tag registry.","error":"Exception: TLV parse error: unknown tag"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}