Closed BVollmerhaus closed 8 months ago
Hi, thanks for the bug report.
Yes, this is a bug that appears to have slipped through - there was a bit of a refactor and it seems this case didn't have a unit test. š
I'll make a fix, add a test and make another point release.
Should all be working again in 4.1.4. Let me know if you have any more issues, and thanks again for the bug report.
Issue
After updating bitstring from 4.1.2 to 4.1.3, the following code no longer functions as expected, instead crashing with a
bitstring.exceptions.CreationError: Token 'bytes' not supplied with a length.
exception:Likewise, reading an arbitrary number of bytes from the current position to the end of the stream now crashes with a
bitstring.exceptions.InterpretError: No length given for dtype 'bytes', and meta type is not fixed length.
:Both cases worked fine with bitstring 4.1.2, so this seems like either an unintentional or undocumented breaking change. When packing a more complex format, it can often be useful to directly include some existing bytes of arbitrary length in one
pack()
operation, hence why I relied onbytes
not requiring a length:Workarounds
Downgrade to bitstring 4.1.2.
At least for packing, a possible workaround is to pack the first part of the stream, append the desired bytes, and ā if needed ā pack the rest separately: