]> granicus.if.org Git - python/commitdiff
Change in when and how stdin and stdout are set to line-buffering.
authorGuido van Rossum <guido@python.org>
Fri, 11 Apr 1997 21:57:53 +0000 (21:57 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 11 Apr 1997 21:57:53 +0000 (21:57 +0000)
This used to be done whenever stdin was interactive.  Now we only do
it when the -i flag is given.  Also (and this is the real reason for
this fix) we explicitly allocate a buffer -- this seems to be
necessary on Windows.

Modules/main.c

index 0cab825157568574c34615a1448f198a0da56046..3057e46f838c2f7d695d99c1e71cddd8b245bab8 100644 (file)
@@ -203,9 +203,11 @@ main(argc, argv)
                setvbuf(stderr, (char *)NULL, _IOLBF, BUFSIZ);
 #endif
        }
-       else if (stdin_is_interactive) {
-               setvbuf(stdin,  (char *)NULL, _IOLBF, BUFSIZ);
-               setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ);
+       else if (Py_InteractiveFlag) {
+               char *ibuffer = malloc(BUFSIZ);
+               char *obuffer = malloc(BUFSIZ);
+               setvbuf(stdin,  ibuffer, _IOLBF, BUFSIZ);
+               setvbuf(stdout, obuffer, _IOLBF, BUFSIZ);
                /* Leave stderr alone - it should be unbuffered anyway. */
        }