← index #17827Issue #13965
Off-topic · high · value 1.505
QUERY · ISSUE

str.center() bug with unicode characters

openby faerotopened 2025-08-04updated 2025-08-11
bugunicode

Port, board and/or hardware

Raspberry Pico; Linux PC

MicroPython version

MicroPython v1.25.0 on 2025-04-15; Raspberry Pi Pico W with RP2040
MicroPython v1.22.1+ds-1build2 on 2024-04-01; linux [GCC 13.2.0]

Reproduction

Run this code in REPL or separately:
print(len('°'.center(4)))

Expected behaviour

Expected to output 4

Observed behaviour

Outputs 3

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

micropython crashes with `print(">>> ", end='')` expression after roughly 0.02 seconds

closedby Kyuchumimoopened 2024-03-02updated 2024-03-02

Checks

  • I agree to follow the MicroPython Code of Conduct to ensure a safe and respectful space for everyone.

  • I've searched for existing issues matching this bug, and didn't find any.

Port, board and/or hardware

rp2

MicroPython version

MicroPython v1.22.2 on 2024-02-22; Raspberry Pi Pico with RP2040

Reproduction

import time

print('>>> ',end='')

while True:
    time.sleep(0.02)
    
    print("THIS SHOULD BE PRINTED!")

Expected behaviour

">>> " string without new line printed on shell

Observed behaviour

For some unknown reason, I can't print exactly what I want, which should be ">>> " without new line escape sequence (\n).

A workaround is to print ">>> \b" (three greater-than signs followed by two spaces and a backspace escape sequence (\b)).

To avoid crashes you need to print something after the print('>>> ',end='') in a time span of roughly less than 0.02 seconds, but as I said before, that is not the goal, i want to print exactly ">>> " without newline or any aditional characters, which I consider to be a bug.

Additional Information

No, I've provided everything above.

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