Improve struct compatibility with CPython#1478
Merged
Merged
Conversation
Member
|
i like this idea - i could use it a lot in libraries! 'x' as well as strictness |
Collaborator
Author
I was doing a lot of and got tired of that. It's in regular Python, so we may as well have it. Didn't take a lot to add. |
Collaborator
Author
|
Travis is 😃 finally. I always forget to do a |
tannewt
approved these changes
Jan 21, 2019
Member
tannewt
left a comment
There was a problem hiding this comment.
Great! Thank you for more compatibility!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
'x'format character tostructformat strings. This designates a padding byte that is0when packing and is skipped when unpacking.struct.unpack()requires the buffer size to match exactly the size required by the format string.struct.unpack_from()requires the buffer size to be at least the size required by the format string (the buffer could be longer).struct.unpack_from(fmt, data, offset=0)now allows offset as a keyword arg. (fixesustruct.unpack_from(fmt, data, offset=0)doesn't allowoffsetto be a keyword #984)I wanted to also add range checking for the arguments for packing (#1451), but that's more difficult, due to how integers are packed internally. Anyway, this gets us closer to compatibility. We had issues with some drivers running on Linux systems with blinka because of the casual checking of
structup to now.Note that we split off from MicroPython when we copied
structfrommodstruct.ctoshared-bindings/shared-module. I made corresponding changes inmodstruct.cbut they aren't used in CircuitPython.Related Micropython issues:
micropython#3736
micropython#1208