From 530997026e8b38ce9c1b7eb970943e05c1ccd1f2 Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Mon, 20 Jul 2026 12:35:53 +1000 Subject: [PATCH] fix(gen): support MicroPython's renamed mp_obj_int_to_bytes() API 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. --- gen/gen_mpy.py | 6 ++++++ gen/lv_mpy_example.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/gen/gen_mpy.py b/gen/gen_mpy.py index ee61a87be2..6e8b7bc118 100644 --- a/gen/gen_mpy.py +++ b/gen/gen_mpy.py @@ -1832,7 +1832,13 @@ def register_int_ptr_type(convertor, *types): unsigned long long val = 0; bool big_endian = !(__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__); + // mp_obj_int_to_bytes() replaced mp_obj_int_to_bytes_impl() in MicroPython + // 1.29 (commit e00daa3a), adding is_signed and overflow_check parameters. +#if MICROPY_VERSION >= MICROPY_MAKE_VERSION(1, 29, 0) + mp_obj_int_to_bytes(obj, sizeof(val), (byte*)&val, big_endian, false, false); +#else mp_obj_int_to_bytes_impl(obj, big_endian, sizeof(val), (byte*)&val); +#endif return val; } diff --git a/gen/lv_mpy_example.c b/gen/lv_mpy_example.c index b109545feb..3957671fd8 100644 --- a/gen/lv_mpy_example.c +++ b/gen/lv_mpy_example.c @@ -778,7 +778,13 @@ STATIC unsigned long long mp_obj_get_ull(mp_obj_t obj) unsigned long long val = 0; bool big_endian = !(__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__); + // mp_obj_int_to_bytes() replaced mp_obj_int_to_bytes_impl() in MicroPython + // 1.29 (commit e00daa3a), adding is_signed and overflow_check parameters. +#if MICROPY_VERSION >= MICROPY_MAKE_VERSION(1, 29, 0) + mp_obj_int_to_bytes(obj, sizeof(val), (byte*)&val, big_endian, false, false); +#else mp_obj_int_to_bytes_impl(obj, big_endian, sizeof(val), (byte*)&val); +#endif return val; }