Skip to content

Blank RuntimeError raised instead of ValueError with message #10259

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

Open
FoamyGuy opened this issue Apr 16, 2025 · 0 comments
Open

Blank RuntimeError raised instead of ValueError with message #10259

FoamyGuy opened this issue Apr 16, 2025 · 0 comments

Comments

@FoamyGuy
Copy link
Collaborator

I've found that the ValueError that the core attempts to raise from here: https://github.com/adafruit/circuitpython/blob/main/shared-bindings/bitmaptools/__init__.c#L369

ends up instead raising a blank RuntimeError when it executes on a PyPortal (tested on 9.2.7, 10.0.0-alpha.2, and build from main)

Traceback (most recent call last):
  File "code.py", line 101, in <module>
RuntimeError: 

I have this reproducer code that causes the problem that should raise the ValueError:

import gc
import math

import bitmaptools
import supervisor
import displayio
import ulab.numpy as np
import adafruit_imageload

display = supervisor.runtime.display
display.auto_refresh = False

main_group = displayio.Group(scale=16)
display.root_group = main_group

bmp = displayio.Bitmap(33, 32, 2**16-1)
tg = displayio.TileGrid(bmp, pixel_shader=displayio.ColorConverter())
main_group.append(tg)

converter = displayio.ColorConverter()

source_bmp1 = displayio.Bitmap(32,32, 2**16-1)
source_bmp1.fill(converter.convert(0x0000ff))
source_bmp2 = displayio.Bitmap(32,32, 2**16-1)
source_bmp2.fill(converter.convert(0xff0000))
print(f"free: {gc.mem_free()}")
print(f"used: {gc.mem_alloc()}")
bitmaptools.alphablend(bmp, source_bmp1, source_bmp2, displayio.Colorspace.RGB565, 1.0, 0.5)

display.refresh()
while True:
    pass

In further testing it seems that the issue may be with specifically the string "Bitmap" in the error message. If I change the message to use a lowercase "b" in the first word then it works and raises the ValueError with message.

If I change the string to "Bitmaq size and bits per value must match" it also works and raises the ValueError with message.

If I run the exact same code on a Feather TFT S3 Reverse with stock 9.2.7 it works and prints the full ValueError and message including the string "Bitmap" which seems to cause it to break on the PyPortal.

@FoamyGuy FoamyGuy changed the title Blank RuntimeError instead of ValueError with message raised Blank RuntimeError raised instead of ValueError with message Apr 16, 2025
@tannewt tannewt added this to the 10.x.x milestone Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants