{"id":9035,"library":"hexrec","title":"Hexadecimal Record File Handler","description":"hexrec is a Python library designed to handle hexadecimal record files, such as Intel HEX and Motorola S-records. It provides tools for parsing, creating, and manipulating these records and converting between raw data blocks and record formats. The current version is 0.5.1, and it maintains an active release cadence with periodic updates to support newer Python versions and improve features.","status":"active","version":"0.5.1","language":"en","source_language":"en","source_url":"https://github.com/d-ganz/hexrec","tags":["hexadecimal","records","intel-hex","motorola-srec","file-parsing","binary-data"],"install":[{"cmd":"pip install hexrec","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"IntelHexRecord","correct":"from hexrec.records import IntelHexRecord"},{"symbol":"MotorolaSrecRecord","correct":"from hexrec.records import MotorolaSrecRecord"},{"note":"The 'base' module was renamed to 'blocks' in v0.2.0.","wrong":"from hexrec.base import Block","symbol":"Block","correct":"from hexrec.blocks import Block"},{"note":"The 'base' module was renamed to 'blocks' in v0.2.0.","wrong":"from hexrec.base import RecordBlock","symbol":"RecordBlock","correct":"from hexrec.blocks import RecordBlock"}],"quickstart":{"code":"from hexrec.blocks import Block\nfrom hexrec.records import IntelHexRecord\n\n# Create a Block instance with an address and data\ndata = b'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07'\nblock = Block(address=0x1000, data=data)\nprint(f\"Created Block: Address=0x{block.address:04X}, Data={block.data.hex()}\")\n\n# Convert the Block to IntelHexRecord instances\nrecords = block.to_records(record_type=IntelHexRecord)\n\nprint(\"Generated Intel HEX Records:\")\nfor record in records:\n    print(record.to_line())\n\n# Example of parsing an Intel HEX record line\nline = ':10100000000102030405060708090A0B0C0D0E0F00'\nparsed_record = IntelHexRecord.from_line(line)\nprint(f\"\\nParsed Record: Address=0x{parsed_record.address:04X}, Data={parsed_record.data.hex()}\")\n","lang":"python","description":"This quickstart demonstrates how to create a data Block, convert it into a list of Intel HEX records, and parse a single Intel HEX record line back into a `IntelHexRecord` object using `hexrec.blocks` and `hexrec.records`."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer, or pin hexrec to a version <0.5.0 if Python 3.8 is required (e.g., `pip install 'hexrec<0.5.0'`).","message":"Python 3.8 support was dropped in hexrec v0.5.0. The minimum required Python version is now 3.9.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Change `from hexrec.records import Record` to `from hexrec.records import BaseRecord` and update your class inheritance if you were directly subclassing `Record`.","message":"The `Record` base class was removed in hexrec v0.3.0. Users subclassing `Record` should now use `BaseRecord`.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Update all references from `.max_data_len` to `.max_data_length` when accessing the maximum data length for record types.","message":"The `max_data_len` attribute on record classes was renamed to `max_data_length` in hexrec v0.3.0.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Update all imports from `from hexrec.base import ...` to `from hexrec.blocks import ...`.","message":"The `hexrec.base` module was renamed to `hexrec.blocks` in hexrec v0.2.0.","severity":"breaking","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Update your import statements: change `from hexrec.base import ...` to `from hexrec.blocks import ...`.","cause":"The module `hexrec.base` was renamed to `hexrec.blocks` in version 0.2.0.","error":"ModuleNotFoundError: No module named 'hexrec.base'"},{"fix":"Replace `.max_data_len` with `.max_data_length` in your code.","cause":"The attribute `max_data_len` was renamed to `max_data_length` in version 0.3.0.","error":"AttributeError: type object 'IntelHexRecord' has no attribute 'max_data_len'"},{"fix":"If you need a base class for custom records, use `hexrec.records.BaseRecord` instead of `hexrec.records.Record`.","cause":"The `Record` base class was removed in version 0.3.0. You are trying to subclass a removed class.","error":"TypeError: type 'hexrec.records.Record' is not an acceptable base type"},{"fix":"Upgrade your Python environment to version 3.9 or higher. If you must use Python 3.8, install an older version of hexrec: `pip install 'hexrec<0.5.0'`.","cause":"Attempting to install or run hexrec v0.5.0 or later on an unsupported Python version.","error":"RuntimeError: You are using Python 3.8. hexrec requires Python 3.9 or newer."}]}