diff options
Diffstat (limited to 'unix/file.c')
-rw-r--r-- | unix/file.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/unix/file.c b/unix/file.c index 448cd50edc..7f113d6712 100644 --- a/unix/file.c +++ b/unix/file.c @@ -35,6 +35,7 @@ #include "py/runtime.h" #include "py/stream.h" #include "py/builtin.h" +#include "py/mphal.h" #if MICROPY_PY_IO @@ -80,6 +81,12 @@ STATIC mp_uint_t fdfile_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errc STATIC mp_uint_t fdfile_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) { mp_obj_fdfile_t *o = MP_OBJ_TO_PTR(o_in); check_fd_is_open(o); + #if MICROPY_PY_OS_DUPTERM + if (o->fd <= STDERR_FILENO) { + mp_hal_stdout_tx_strn(buf, size); + return size; + } + #endif mp_int_t r = write(o->fd, buf, size); if (r == -1) { *errcode = errno; |