Skip to content

uctypes does not support values larger than 31 bits despite listing uint64 support #2269

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

Closed
ryannathans opened this issue Jul 28, 2016 · 4 comments

Comments

@ryannathans
Copy link
Contributor

ryannathans commented Jul 28, 2016

>>> struct = uctypes.struct(uctypes.addressof(buffer), {"bug": uctypes.UINT32 | 0, "bug64": uctypes.UINT64 | 4})
>>> struct.bug = 2147483647
>>> struct.bug = 2147483648
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: overflow converting long int to machine word
>>> struct.bug64 = 2147483647
>>> struct.bug64 = 2147483648
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: overflow converting long int to machine word

Seems pretty funny how ctypes can't support UINT32 and UINT64s?

@pfalcon
Copy link
Contributor

pfalcon commented Aug 25, 2016

To fix this, we need getters for getting Python int object as: int32, uint32, int64, uint64, each apparently "truncated" and "range checking" version. That's many getters, so apparently there should be one new function, taking flags for the above, deprecating previously available mp_obj_int_get_truncated() & mp_obj_int_get_checked().

@dpgeorge
Copy link
Member

Just using mp_obj_int_get_truncated should fix the 32 bit case. Then there are already some functions to handle wider values, eg int_to_bytes() and mp_obj_int_to_bytes_impl().

ryannathans referenced this issue Sep 22, 2016
Use mp_obj_int_get_truncated to allow the full 32-bit address range
as first parameter.
@pfalcon
Copy link
Contributor

pfalcon commented Apr 20, 2017

Ok, I have fixes for these working on 32-bit little-endian, now the most boring part is writing tests...

@pfalcon
Copy link
Contributor

pfalcon commented Apr 21, 2017

Fixed by 9e8f316

@pfalcon pfalcon closed this as completed Apr 21, 2017
tannewt pushed a commit to tannewt/circuitpython that referenced this issue Nov 16, 2019
Add board configuration for Winterbloom Sol
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

No branches or pull requests

3 participants