summaryrefslogtreecommitdiffstats
path: root/Modules/main.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-01-09 18:53:14 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-01-09 18:53:14 (GMT)
commit0560843b8fe8d4dd9e830f7b3ae7984154914516 (patch)
treebe1fabb299e11cdc957e653592bbc7d658a9fc07 /Modules/main.c
parent1483140772c3f6c4c1674f0fbfcaaa1b350d27a1 (diff)
downloadcpython-0560843b8fe8d4dd9e830f7b3ae7984154914516.zip
cpython-0560843b8fe8d4dd9e830f7b3ae7984154914516.tar.gz
cpython-0560843b8fe8d4dd9e830f7b3ae7984154914516.tar.bz2
Issue #4705: Fix the -u ("unbuffered binary stdout and stderr") command-line
flag to work properly. Furthermore, when specifying -u, the text stdout and stderr streams have line-by-line buffering enabled (the default being to buffer arbitrary chunks of data). Patch by Victor Stinner, test by me.
Diffstat (limited to 'Modules/main.c')
-rw-r--r--Modules/main.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 3025d09..6de1523 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -292,7 +292,6 @@ Py_Main(int argc, wchar_t **argv)
wchar_t *module = NULL;
FILE *fp = stdin;
char *p;
- int unbuffered = 0;
int skipfirstline = 0;
int stdin_is_interactive = 0;
int help = 0;
@@ -374,7 +373,7 @@ Py_Main(int argc, wchar_t **argv)
break;
case 'u':
- unbuffered++;
+ Py_UnbufferedStdioFlag = 1;
saw_unbuffered_flag = 1;
break;
@@ -423,7 +422,7 @@ Py_Main(int argc, wchar_t **argv)
Py_InspectFlag = 1;
if (!saw_unbuffered_flag &&
(p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0')
- unbuffered = 1;
+ Py_UnbufferedStdioFlag = 1;
if (!Py_NoUserSiteDirectory &&
(p = Py_GETENV("PYTHONNOUSERSITE")) && *p != '\0')
@@ -444,7 +443,7 @@ Py_Main(int argc, wchar_t **argv)
stdin_is_interactive = Py_FdIsInteractive(stdin, (char *)0);
- if (unbuffered) {
+ if (Py_UnbufferedStdioFlag) {
#if defined(MS_WINDOWS) || defined(__CYGWIN__)
_setmode(fileno(stdin), O_BINARY);
_setmode(fileno(stdout), O_BINARY);