8000 extmod/vfs_posix_file: Fix flush handling in msvc builds. · micropython/micropython@cac666f · GitHub
[go: up one dir, main page]

Skip to content

Commit cac666f

Browse files
stinosdpgeorge
authored andcommitted
extmod/vfs_posix_file: Fix flush handling in msvc builds.
Flushing console output in msvc builds always fails because that output is not buffered so don't propagate that as an error (in a simlar way as was done in 1c04774 for macOS). Signed-off-by: stijn <stijn@ignitron.net>
1 parent 92717a9 commit cac666f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

â 8000 €Žextmod/vfs_posix_file.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,14 @@ STATIC mp_uint_t vfs_posix_file_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_
153153
switch (request) {
154154
case MP_STREAM_FLUSH: {
155155
int ret;
156-
// fsync(stdin/stdout/stderr) may fail with EINVAL (or ENOTSUP on macos),
157-
// but don't propagate that error out. Because data is not buffered by
158-
// us, and stdin/out/err.flush() should just be a no-op.
159-
#ifdef __APPLE__
156+
// fsync(stdin/stdout/stderr) may fail with EINVAL (or ENOTSUP on macos or EBADF
157+
// on windows), because the OS doesn't buffer these except for instance when they
158+
// are redirected from/to file, but don't propagate that error out. Because data
159+
// is not buffered by us, and stdin/out/err.flush() should just be a no-op.
160+
#if defined(__APPLE__)
160161
#define VFS_POSIX_STREAM_STDIO_ERR_CATCH (err == EINVAL || err == ENOTSUP)
162+
#elif defined(_MSC_VER)
163+
#define VFS_POSIX_STREAM_STDIO_ERR_CATCH (err == EINVAL || err == EBADF)
161164
#else
162165
#define VFS_POSIX_STREAM_STDIO_ERR_CATCH (err == EINVAL)
163166
#endif

0 commit comments

Comments
 (0)
0