summaryrefslogtreecommitdiff
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-10-04 20:25:40 +0300
committerGitHub <noreply@github.com>2017-10-04 20:25:40 +0300
commit77732be801c18013cfbc86e27fcc50194ca22c8e (patch)
tree994379199522db4d759f5759655ad0c466e7fdab /Python/pylifecycle.c
parent0b5e61ddca73ad4fe597fb15065115b0285c8849 (diff)
downloadcpython-git-77732be801c18013cfbc86e27fcc50194ca22c8e.tar.gz
bpo-30404: The -u option now makes the stdout and stderr streams totally unbuffered. (#1667)
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 4b0383b429..5b13bc4582 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -1498,7 +1498,7 @@ create_stdio(PyObject* io,
PyObject *buf = NULL, *stream = NULL, *text = NULL, *raw = NULL, *res;
const char* mode;
const char* newline;
- PyObject *line_buffering;
+ PyObject *line_buffering, *write_through;
int buffering, isatty;
_Py_IDENTIFIER(open);
_Py_IDENTIFIER(isatty);
@@ -1555,7 +1555,11 @@ create_stdio(PyObject* io,
Py_DECREF(res);
if (isatty == -1)
goto error;
- if (isatty || Py_UnbufferedStdioFlag)
+ if (Py_UnbufferedStdioFlag)
+ write_through = Py_True;
+ else
+ write_through = Py_False;
+ if (isatty && !Py_UnbufferedStdioFlag)
line_buffering = Py_True;
else
line_buffering = Py_False;
@@ -1574,9 +1578,9 @@ create_stdio(PyObject* io,
newline = "\n";
#endif
- stream = _PyObject_CallMethodId(io, &PyId_TextIOWrapper, "OsssO",
+ stream = _PyObject_CallMethodId(io, &PyId_TextIOWrapper, "OsssOO",
buf, encoding, errors,
- newline, line_buffering);
+ newline, line_buffering, write_through);
Py_CLEAR(buf);
if (stream == NULL)
goto error;