Skip to content

Raise NotImplementedError for byte and bit order in the C implementation - #62

Open
anirudh12032008 wants to merge 1 commit into
eerimoq:masterfrom
anirudh12032008:fix-c-reject-byte-order
Open

anirudh12032008 wants to merge 1 commit into
eerimoq:masterfrom
anirudh12032008:fix-c-reject-byte-order

Conversation

@anirudh12032008

Copy link
Copy Markdown

Fixes #61.

bitstruct.c ignores a trailing < and packs big endian, so c.pack('u16<', 1) gives b'\x00\x01' where the pure Python version gives b'\x01\x00'. A leading > or < is parsed as the field type and fails with "Field of size 0.".

The README already lists byte/bit order as unsupported. This makes the C parser say so (NotImplementedError, like the other documented limits) for <, and accepts > since it is the default. Both go through parse_field / parse_format, so pack, unpack, compiled formats and the dict variants are all covered.

Added test_byte_order to tests/test_c.py; it fails before the change and python -m unittest passes after (52 tests).

The C implementation silently ignored a trailing '<', packing big
endian data, and rejected '<' and '>' in front of a field with
"Field of size 0.". Raise NotImplementedError for '<' as documented,
and accept '>' as the default.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bitstruct.c silently ignores a trailing < and rejects >/< in front of a field

1 participant