← index #11099Issue #18837
Off-topic · high · value 4.494
QUERY · ISSUE

Binary stdin and stdout buffers for Unix port

openby smurfixopened 2023-03-22updated 2023-03-30
enhancement
$ micropython
>>> import sys
>>> sys.stdout.buffer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'TextIOWrapper' object has no attribute 'buffer'
>>>

Well, other ports have it … CPython has it … and I'd really like to not have to fall back to open("/dev/stdout","wb") in my unit tests.

Same for stdin of course.

CANDIDATE · ISSUE

Enabling DUPTERM on Unix kills output to stderr

openby smurfixopened 2026-02-18updated 2026-03-14
bugport-unix

Port, board and/or hardware

Unix

MicroPython version

current master, v1.27.0-175-ga8b71559cf-dirty

Reproduction

Adding

#define MICROPY_PY_OS_DUPTERM (2)

to ports/unix/mpconfigport.h disables writing to standard error. Output is sent to stdout instead.

Expected behaviour

$ ports/unix/build-standard/micropython -c "import sys;print('XXX',file=sys.stderr)" >/dev/null
XXX
$ 

Observed behaviour

$ ports/unix/build-standard/micropython -c "import sys;print('XXX',file=sys.stderr)" >/dev/null
[ no output ]
$ 

Additional Information

>>> import sys
>>> sys.stdout
<io.TextIOWrapper 1>
>>> sys.stderr
<io.TextIOWrapper 2>

but print or write don't seem to care.

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