← index #3356Issue #11253
Off-topic · high · value 0.335
QUERY · ISSUE

[baremetal] sys.stdin does not handle ctrl-D EOF markers

openby dhalbertopened 2017-10-07updated 2017-10-21

sys.stdin.read(), sys.stdin.readlines(), etc. do not handle ctrl-D at the beginning of a line as EOF (except on ports like unix). So for instance, there's no way to terminate input when doing sys.stdin.readlines().

Is this something that should mimic CPython on an OS-less port? Some lower-level stream read routine could check if the stream was sys.stdin and handle ctrl-D specially.

(tested on esp8266 port)

CANDIDATE · ISSUE

On RP2 sys.stdin.read(64) and sys.stdin.readline() do not work if we have multiple of 64 bytes in buffer

closedby pchalaopened 2023-04-13updated 2023-04-25
port-rp2

MicroPython v1.19.1-994-ga4672149b on 2023-03-29; Raspberry Pi Pico with RP2040

Pico code:

import sys

while True:
    line = sys.stdin.read(64)
    print(len(line))

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