unix/file: Don't raise OSError(EINVAL) on sys.stdin/out/err.flush().
sys.stdout.flush() is needed on CPython to flush the output, and the change in this commit makes such an expression also work on MicroPython (although MicroPython doesn't actual need to do any flushing).
This commit is contained in:
@@ -126,6 +126,13 @@ STATIC mp_uint_t fdfile_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, i
|
|||||||
int ret = fsync(o->fd);
|
int ret = fsync(o->fd);
|
||||||
MP_THREAD_GIL_ENTER();
|
MP_THREAD_GIL_ENTER();
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
|
if (errno == EINVAL
|
||||||
|
&& (o->fd == STDIN_FILENO || o->fd == STDOUT_FILENO || o->fd == STDERR_FILENO)) {
|
||||||
|
// fsync(stdin/stdout/stderr) may fail with EINVAL, but don't propagate that
|
||||||
|
// error out. Because data is not buffered by us, and stdin/out/err.flush()
|
||||||
|
// should just be a no-op.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
*errcode = errno;
|
*errcode = errno;
|
||||||
return MP_STREAM_ERROR;
|
return MP_STREAM_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user