forked from MostAwesomeDude/construct
-
Notifications
You must be signed in to change notification settings - Fork 165
Closed
Labels
Description
If you try to read x more bits than are available using a BitsInteger, the error message incorrectly states that you are trying to request x extra bytes, not bits.
Example code:
from construct import BitStruct, Bit, BitsInteger
MY_MESSAGE = BitStruct(
Bit[7],
BitsInteger(17)
)
MY_MESSAGE.parse(b'A')Traceback (most recent call last):
File "test.py", line 8, in <module>
MY_MESSAGE.parse(b'A')
File "env\lib\site-packages\construct\core.py", line 165, in parse
return self.parse_stream(BytesIO(data), context, **kw)
File "env\lib\site-packages\construct\core.py", line 176, in parse_stream
return self._parse(stream, context, "parsing")
File "env\lib\site-packages\construct\core.py", line 1791, in _parse
obj = self.subcon._parse(self.stream2, context, path)
File "env\lib\site-packages\construct\core.py", line 849, in _parse
subobj = sc._parse(stream, context, path)
File "env\lib\site-packages\construct\core.py", line 576, in _parse
data = _read_stream(stream, length)
File "env\lib\site-packages\construct\core.py", line 72, in _read_stream
data = stream.read(length)
File "env\lib\site-packages\construct\lib\bitstream.py", line 26, in read
raise IOError("Restreamed cannot satisfy read request of %d bytes" % count)
OSError: Restreamed cannot satisfy read request of 17 bytes
While trying to parse a complicated object, I was confused as to what combination of my bit fields added to the number of bytes presented in the error message.
In the above example, it should report OSError: Restreamed cannot satisfy read request of 17 bits
Reactions are currently unavailable