Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b31c7dc

Browse files
committed
OK, I lied. On Windows, _IOLBF seems to be the same as full
buffering, so to get the normal behavior back, I set it to unbuffered.
1 parent 2a21219 commit b31c7dc

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

Modules/main.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,14 @@ main(argc, argv)
204204
#endif
205205
}
206206
else if (Py_InteractiveFlag) {
207-
char *ibuffer = malloc(BUFSIZ);
208-
char *obuffer = malloc(BUFSIZ);
209-
setvbuf(stdin, ibuffer, _IOLBF, BUFSIZ);
210-
setvbuf(stdout, obuffer, _IOLBF, BUFSIZ);
207+
#ifdef MS_WINDOWS
208+
/* Doesn't have to have line-buffered -- use unbuffered */
209+
setvbuf(stdin, (char *)NULL, _IONBF, BUFSIZ);
210+
setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ);
211+
#else
212+
setvbuf(stdin, (char *)NULL, _IOLBF, BUFSIZ);
213+
setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ);
214+
#endif
211215
/* Leave stderr alone - it should be unbuffered anyway. */
212216
}
213217

0 commit comments

Comments
 (0)