← index #14376Issue #13965
Off-topic · high · value 0.991
QUERY · ISSUE

Assignment expression raises error if updating global variable

openby rkompassopened 2024-04-25updated 2024-04-25
bug

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

w600, RP2, others

MicroPython version

MicroPython v1.23.0-preview.362.g3995158d9.dirty on 2024-04-19

Reproduction

a=0; print([(a:=a+1) for b in range(10)])

Expected behaviour

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Observed behaviour

SyntaxError: identifier redefined as global

Additional Information

I saw the discussion on https://github.com/micropython/micropython/pull/4908
but there it is about a variable created in the comprehension context being available as global outside.

Here is a variable already present as global.

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