New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error message says 'bytes', not bits when there aren't enough bits for BitsInteger #360
Comments
That is not entirely a bug. You see, some classes are kind of agnostic with bits and bytes, so to make the story short, its just all called bytes. BitStream which is the class raising the exception does NOT know whether there are bits or bytes that are being processed. Despite the name of the class. Its a universal class that transforms bits->bytes and bytes->bits but can also do other transformations. |
I now understand that it is a agnostic class and that it might be a non-trivial change. But from a user friendliness perspective, this error message is definitely not ideal. |
Other similar messages: print(BitsInteger(8).parse('111')) gives
print(BitStruct(BitsInteger(7)).parse(b'\xFF')) gives
|
There is no point adding more examples. I wont be able to change these messages. All these classes are bit/byte agnostic. They DO NOT KNOW the difference. I wont close the issue because that could be considered rude, but its a mute point. |
It could be done without too many lines changed. I've made a commit to my fork that implements it. If you're interested, I'll make it a Pull Request. |
Hmm I am in a good mood so yeah sure, send me a PR. At least I can take a look and thank you for the effort, if not merge it. 😄 |
Took a look at your link. Hah this fix was so simple I didnt even think of it. I like it, sure I can merge it. Only one small request, can you make string literals consistent? Double quotes are used throughout the codebase. |
Very good PR, much welcomed. I personally see this bytes/bits issue mute, to me its kinds same-same but I see why other people might prefer the error messages to be more precise. |
If you try to read
x
more bits than are available using a BitsInteger, the error message incorrectly states that you are trying to requestx
extra bytes, not bits.Example code:
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
The text was updated successfully, but these errors were encountered: