From 317ea299cc2e902d4b00534f50275bdf0d19e14c Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Fri, 8 May 2026 21:33:52 +0300 Subject: [PATCH] Fix error message formatting in uf2conv Some of the error messages were trying to concatenate int to str. This gave "TypeError: can only concatenate str (not "int") to str" Fixed the formatting and made the errors more helpful by including the addresses involved. --- utils/uf2conv.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/utils/uf2conv.py b/utils/uf2conv.py index 5a862c3..ef273e2 100755 --- a/utils/uf2conv.py +++ b/utils/uf2conv.py @@ -48,7 +48,7 @@ def convert_from_uf2(buf): block = buf[ptr:ptr + 512] hd = struct.unpack(b" 10*1024*1024: - assert False, "More than 10M of padding needed at " + ptr - if padding % 4 != 0: - assert False, "Non-word padding size at " + ptr + assert padding >= 0, "Block out of order at 0x{:08x}: new address 0x{:08x}, old address 0x{:08x}".format(ptr, newaddr, curraddr) + assert padding <= 10*1024*1024, "More than 10M of padding needed at 0x{:08x}: new address 0x{:08x}, old address 0x{:08x}".format(ptr, newaddr, curraddr) + assert padding % 4 == 0, "Non-word padding size at 0x{:08x}: new address 0x{:08x}, old address 0x{:08x}".format(ptr, newaddr, curraddr) while padding > 0: padding -= 4 outp.append(b"\x00\x00\x00\x00")