← index #15275Issue #16053
Off-topic · high · value 1.648
QUERY · ISSUE

Cannot instantiate FrameBuffer from a bytes object

openby peterhinchopened 2024-06-13updated 2026-03-20
bugextmod

Port, board and/or hardware

RP2, Pyboard 1.1

MicroPython version

MicroPython v1.22.1 on 2024-01-05; Raspberry Pi Pico with RP2040

Reproduction

Enter the following at the REPL:

from framebuf import FrameBuffer, GS8
b = b'\x00' * 100
f = FrameBuffer(b, 10, 10, GS8)

Expected behaviour

I would expect the instantiation of the FrameBuffer to succeed (as it does if a bytearray is passed).

Observed behaviour

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: object with buffer protocol required

Additional Information

Use case:
Instantiating from a bytes object (or a memoryview of bytes) would enable graphical objects frozen as bytecode to be blitted onto an existing frame buffer.

A further observation: the error message is most misleading.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

`FrameBuffer.ellipse` goes into infinite loop with 0 radius

closedby corranwebsteropened 2024-10-21updated 2024-11-28
bug

Port, board and/or hardware

unix, RP2

MicroPython version

MicroPython v1.23.0 on 2024-06-02; Raspberry Pi Pico with RP2040
MicroPython v1.23.0 on 2024-05-31; darwin [GCC 4.2.1] version

Reproduction

In an interactive session (or otherwise), run the following code:

import framebuf
buf = bytearray(10*10*2)
f = framebuf.FrameBuffer(buf, 10, 10, framebuf.RGB565)
f.ellipse(5, 5, 0, 0, 0xffff, True)

Expected behaviour

Nothing should be drawn. Code should complete normally.

Maybe an exception should be raised, but I think it's OK to just draw nothing.

Observed behaviour

Micropython hangs; 100% CPU usage observed in unix port. Strong suspicion this is an infinite loop.

Additional Information

I'm very suspicious of the following code: https://github.com/micropython/micropython/blob/1b89c503db690967d50699abe0bfa942f6f6b15e/extmod/modframebuf.c#L542-L554

In this case two_asquare and two_bsquare are both 0, so the stoppingx and stoppingy look like they are never changed, but I haven't 100% proven it to myself.

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied