Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 50678:9c2bd647b646 3.0
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.
........
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Fri, 09 Jan 2009 22:26:34 +0000 |
| parents | b98fe8dc8acd |
| children | 14c3ab9bd706 |
comparison
equal
deleted
inserted
replaced
| 50670:9b276ce35697 | 50678:9c2bd647b646 |
|---|---|
| 732 static PyObject* | 732 static PyObject* |
| 733 create_stdio(PyObject* io, | 733 create_stdio(PyObject* io, |
| 734 int fd, int write_mode, char* name, | 734 int fd, int write_mode, char* name, |
| 735 char* encoding, char* errors) | 735 char* encoding, char* errors) |
| 736 { | 736 { |
| 737 PyObject *buf = NULL, *stream = NULL, *text = NULL, *raw = NULL; | 737 PyObject *buf = NULL, *stream = NULL, *text = NULL, *raw = NULL, *res; |
| 738 const char* mode; | 738 const char* mode; |
| 739 const PyObject *line_buffering; | 739 PyObject *line_buffering; |
| 740 int buffering; | 740 int buffering, isatty; |
| 741 | 741 |
| 742 if (Py_UnbufferedStdioFlag) | 742 if (Py_UnbufferedStdioFlag) |
| 743 buffering = 0; | 743 buffering = 0; |
| 744 else | 744 else |
| 745 buffering = -1; | 745 buffering = -1; |
| 764 } | 764 } |
| 765 | 765 |
| 766 text = PyUnicode_FromString(name); | 766 text = PyUnicode_FromString(name); |
| 767 if (text == NULL || PyObject_SetAttrString(raw, "_name", text) < 0) | 767 if (text == NULL || PyObject_SetAttrString(raw, "_name", text) < 0) |
| 768 goto error; | 768 goto error; |
| 769 Py_CLEAR(raw); | 769 res = PyObject_CallMethod(raw, "isatty", ""); |
| 770 Py_CLEAR(text); | 770 if (res == NULL) |
| 771 | 771 goto error; |
| 772 if (Py_UnbufferedStdioFlag) | 772 isatty = PyObject_IsTrue(res); |
| 773 Py_DECREF(res); | |
| 774 if (isatty == -1) | |
| 775 goto error; | |
| 776 if (isatty || Py_UnbufferedStdioFlag) | |
| 773 line_buffering = Py_True; | 777 line_buffering = Py_True; |
| 774 else | 778 else |
| 775 line_buffering = Py_False; | 779 line_buffering = Py_False; |
| 780 | |
| 781 Py_CLEAR(raw); | |
| 782 Py_CLEAR(text); | |
| 783 | |
| 776 stream = PyObject_CallMethod(io, "TextIOWrapper", "OsssO", | 784 stream = PyObject_CallMethod(io, "TextIOWrapper", "OsssO", |
| 777 buf, encoding, errors, | 785 buf, encoding, errors, |
| 778 "\n", line_buffering); | 786 "\n", line_buffering); |
| 779 Py_CLEAR(buf); | 787 Py_CLEAR(buf); |
| 780 if (stream == NULL) | 788 if (stream == NULL) |
