fix(gen): support MicroPython's renamed mp_obj_int_to_bytes() API - #411
fix(gen): support MicroPython's renamed mp_obj_int_to_bytes() API#411andrewleech wants to merge 1 commit into
Conversation
MicroPython commit e00daa3a ("py/binary,objint: Add overflow checks and
int.to_bytes(signed=True)") renamed mp_obj_int_to_bytes_impl() to
mp_obj_int_to_bytes() with a new signature (adding is_signed and
overflow_check parameters), for the 1.29 release. The generated binding
called the old name unconditionally in mp_obj_get_ull(), so building against
1.29 or later failed to link with an undefined reference to
mp_obj_int_to_bytes_impl.
Guard the call on MICROPY_VERSION so the binding builds against both APIs.
9a4d2d1 to
5309970
Compare
|
Confirming independent testing on the unix port (you noted you hadn't tried it): rebuilt Side note: this is very likely also why the |
|
Confirming this also fixes the unix port, since the description notes it wasn't tested there. Applied the same guard to Built and ran it repeatedly (dozens of rebuilds over the last day), including live LVGL UI code -- buttons, labels, style colors, indev state -- that routes through So: confirmed working on unix in addition to the mimxrt testing already in the description. |
|
Confirming this also fixes the unix port (the description notes it wasn't tested there): built Worth calling out how live this bug currently is: CI on We've got a follow-up PR (#413) building on top of this one - adds LVGL's native Wayland driver, and separately fixes a regression that's kept every desktop window driver (SDL included) out of the Python bindings since May. Rebasing that once this lands. |
Summary
MicroPython commit e00daa3a ("py/binary,objint: Add overflow checks and
int.to_bytes(signed=True)") renamedmp_obj_int_to_bytes_impl()tomp_obj_int_to_bytes()and changed its signature, addingis_signedandoverflow_checkparameters. The generated binding calls this helper inmp_obj_get_ull(), so building against MicroPython 1.29 or later fails to link withundefined reference to 'mp_obj_int_to_bytes_impl'.This guards the call on
MICROPY_VERSION >= MICROPY_MAKE_VERSION(1, 29, 0), calling the new API on 1.29+ and the old one on earlier versions. The reverse helpermp_obj_int_from_bytes_impl()was not renamed and is unchanged.lv_micropython merges the upstream MicroPython master that carries the rename, so it needs the same fix: lvgl/lv_micropython#106.
Testing
Built the binding into a MicroPython firmware for an i.MX RT1176 board (mimxrt port, arm-none-eabi) against a 1.29 MicroPython: it links, and
mp_obj_get_ull()compiles themp_obj_int_to_bytes()call. The pre-1.29 branch of the guard was checked by preprocessing against a 1.24 header, which selects the old call.I did not test the unix port.
Generative AI
I used generative AI tools when creating this PR, but a human has checked the code and is responsible for the code and the description above.