Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

msgpack doesn't support full range of int32 #7388

Open
thetazero opened this issue Dec 27, 2022 · 2 comments · May be fixed by #7811
Open

msgpack doesn't support full range of int32 #7388

thetazero opened this issue Dec 27, 2022 · 2 comments · May be fixed by #7811
Assignees
Labels
Milestone

Comments

@thetazero
Copy link

CircuitPython version

7.3.0-beta.1-4-g7be66a573-dirtyAdafruit CircuitPython 7.3.0-beta.1-4-g7be66a573-dirty on 2022-04-15; PyCubedMini with samd51j19

Code/REPL

>>> msgpack.pack([1672099392], BytesIO())

Behavior

Traceback (most recent call last):
File "", line 1, in
ValueError: no default packer

Description

This behavior is seen when passing ints greater than 2^30, which seems very strange.

I suspect it has something to do with the call to the function mp_obj_is_small_int: here.

For some reason it is not entering

if (mp_obj_is_small_int(obj)) {
        // int
        int32_t x = MP_OBJ_SMALL_INT_VALUE(obj);
        pack_int(s, x);
    }

And continues until the failure case

            mp_raise_ValueError(translate("no default packer"));

Additional information

No response

@thetazero thetazero added the bug label Dec 27, 2022
@dhalbert
Copy link
Collaborator

I think this intersects with #6851.

@dhalbert dhalbert added this to the 8.x.x milestone Dec 30, 2022
@tannewt
Copy link
Member

tannewt commented Jan 4, 2023

@thetazero Small ints are stored in 30 bits themselves because they are stored in pointers with 2 bits to indicate what type of data it is. So, you are right that the small int check isn't correct. It should be more generic to handle any int. (Ints >2**30 are stored as objects rather than small ints in a pointer.)

@Neradoc Neradoc linked a pull request Mar 29, 2023 that will close this issue
@jepler jepler modified the milestones: 8.x.x, Long term Jun 21, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants