python-intelhex / intelhex

Python IntelHex library
BSD 3-Clause "New" or "Revised" License
198 stars 106 forks source link

list(ih) causes the Python interpreter to hang up #54

Closed jfongattw closed 3 years ago

jfongattw commented 3 years ago

from intelhex import IntelHex ih = IntelHex() ih[0] = 0x55 list(ih)

The-42 commented 3 years ago

__getitem__() currently returns either actual bytes for valid addresses or padding bytes for non-existing non-negative addresses. While this is by design, this admittedly is a problem when creating a list from an IntelHex object... A fix would probably be to raise an IndexError when breaching the current maximum address. This would yield empty lists for empty objects and make list generation finite for objects containing data. I'm looking into it.