Skip to content

Commit 5f26625

Browse files
committed
fix(py): io.flush raises OSError on SIGXFSZ
1 parent 54d8544 commit 5f26625

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/pylib/Lib/io.nim

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export FileNotFoundError
3838

3939
import ./os_impl/posix_like/truncate
4040
import ./os_impl/posix_like/isatty
41+
import ./signal_impl/state
42+
discard signal_global_state
4143
import ./ncodec
4244
export DefErrors, LookupError
4345
import ../pystring/[strimpl, strbltins]
@@ -69,7 +71,12 @@ type
6971

7072
converter toUnderFile(f: IOBase): File = f.file
7173

72-
proc flush*(f: IOBase) = f.flushFile()
74+
proc c_fflush(f: File): cint {.
75+
importc: "fflush", header: "<stdio.h>".}
76+
proc flush*(f: IOBase) =
77+
let ret = f.c_fflush()
78+
if ret != 0:
79+
raiseErrno()
7380

7481
func tell*(f: IOBase): int64 = f.getFilePos()
7582

0 commit comments

Comments
 (0)