QUERY · ISSUE
Binary stdin and stdout buffers for Unix port
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
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