Skip to content
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

raw bytes elements #5

Open
sprout42 opened this issue Aug 29, 2016 · 4 comments
Open

raw bytes elements #5

sprout42 opened this issue Aug 29, 2016 · 4 comments

Comments

@sprout42
Copy link
Owner

Define an element type which allows supplying and returning bytearray values, rather than forcing bytes-like data to be fit into integer/numerical values.

@sprout42
Copy link
Owner Author

hmm.... what if we take a cue from how we determine bytes vs. elements in the length field, and if a numeric element's name is specified as b'name' then it will unpack as bytes? I think numeric elements already support bytes as one of the valid input data formats.

@sprout42
Copy link
Owner Author

If we have a simple method to mark that the unpacked data should be bytes vs. a number then all we need to do is skip this line in the unpack function:

val = int.from_bytes(b''.join(data), # pylint: disable=no-member

@tjdevries
Copy link
Collaborator

Line 123 should probably be a bytearray rather than a list, but yeah, I think that would work.

@sprout42
Copy link
Owner Author

good point, I hadn't considered having it a bytearray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants