Add unsigned ints and 64 bit types to msgpack.unpack #7802
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add missing formats to msgpack unpack.
In
mspack.unpack()
C python seems to always use doubles for floats, and seems to use unsigned ints for positive integers, so this should fix unpacking msgpack payloads from C python. I also discovered in tests that the previous implementation would drop high bits in 32-bits ints instead of erroring or using big ints (for numbers that don't fit in a small int).
Error message changed, since
0xc1
is now the only invalid byte, as it is in the specs.(Is there an existing message that could be reused ?)
This PR doesn't change the int packing behavior, which is still limited to small ints.
I did not add conditional compiling for ports without big ints, because if you can't fit big ints, you can't fit msgpack.
[Non exhaustive] Test code below for the new features, unpacking bytes generated from C python or manually.