summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-01-09 22:26:34 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-01-09 22:26:34 (GMT)
commit1d9990b291b017f53f13c0488d2e4a5ce16ffc60 (patch)
treeb69ee7c9c361a37fad44cbc7d62da1e3b9d9cdbb /Python/pythonrun.c
parent784b4ac30f5a36ed243c6a73ad90bf27150d171c (diff)
downloadcpython-1d9990b291b017f53f13c0488d2e4a5ce16ffc60.zip
cpython-1d9990b291b017f53f13c0488d2e4a5ce16ffc60.tar.gz
cpython-1d9990b291b017f53f13c0488d2e4a5ce16ffc60.tar.bz2
Merged revisions 68463 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r68463 | antoine.pitrou | 2009-01-09 23:12:30 +0100 (ven., 09 janv. 2009) | 4 lines Fix bug introduced in r68451: stdio must always be opened in line-buffered mode if isatty() is true. ........
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 8a1af3b..6819be5 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -734,10 +734,10 @@ create_stdio(PyObject* io,
int fd, int write_mode, char* name,
char* encoding, char* errors)
{
- PyObject *buf = NULL, *stream = NULL, *text = NULL, *raw = NULL;
+ PyObject *buf = NULL, *stream = NULL, *text = NULL, *raw = NULL, *res;
const char* mode;
- const PyObject *line_buffering;
- int buffering;
+ PyObject *line_buffering;
+ int buffering, isatty;
if (Py_UnbufferedStdioFlag)
buffering = 0;
@@ -766,13 +766,21 @@ create_stdio(PyObject* io,
text = PyUnicode_FromString(name);
if (text == NULL || PyObject_SetAttrString(raw, "_name", text) < 0)
goto error;
- Py_CLEAR(raw);
- Py_CLEAR(text);
-
- if (Py_UnbufferedStdioFlag)
+ res = PyObject_CallMethod(raw, "isatty", "");
+ if (res == NULL)
+ goto error;
+ isatty = PyObject_IsTrue(res);
+ Py_DECREF(res);
+ if (isatty == -1)
+ goto error;
+ if (isatty || Py_UnbufferedStdioFlag)
line_buffering = Py_True;
else
line_buffering = Py_False;
+
+ Py_CLEAR(raw);
+ Py_CLEAR(text);
+
stream = PyObject_CallMethod(io, "TextIOWrapper", "OsssO",
buf, encoding, errors,
"\n", line_buffering);