comparison Python/pythonrun.c @ 51082:14c3ab9bd706 3.0

Merged revisions 68977,68981 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r68977 | antoine.pitrou | 2009-01-26 22:48:00 +0100 (lun., 26 janv. 2009) | 3 lines Followup of #4705: we can't skip the binary buffering layer for stdin because FileIO doesn't have a read1() method ........ r68981 | antoine.pitrou | 2009-01-26 23:00:21 +0100 (lun., 26 janv. 2009) | 3 lines Fix test so as to also pass in debug mode ........
author Antoine Pitrou <solipsis@pitrou.net>
date Mon, 26 Jan 2009 22:03:09 +0000
parents 9c2bd647b646
children fa3b2ed20d85 8fe2988cf550
comparison
equal deleted inserted replaced
51072:b04896caa29b 51082:14c3ab9bd706
737 PyObject *buf = NULL, *stream = NULL, *text = NULL, *raw = NULL, *res; 737 PyObject *buf = NULL, *stream = NULL, *text = NULL, *raw = NULL, *res;
738 const char* mode; 738 const char* mode;
739 PyObject *line_buffering; 739 PyObject *line_buffering;
740 int buffering, isatty; 740 int buffering, isatty;
741 741
742 if (Py_UnbufferedStdioFlag) 742 /* stdin is always opened in buffered mode, first because it shouldn't
743 make a difference in common use cases, second because TextIOWrapper
744 depends on the presence of a read1() method which only exists on
745 buffered streams.
746 */
747 if (Py_UnbufferedStdioFlag && write_mode)
743 buffering = 0; 748 buffering = 0;
744 else 749 else
745 buffering = -1; 750 buffering = -1;
746 if (write_mode) 751 if (write_mode)
747 mode = "wb"; 752 mode = "wb";
751 fd, mode, buffering, 756 fd, mode, buffering,
752 Py_None, Py_None, Py_None, 0); 757 Py_None, Py_None, Py_None, 0);
753 if (buf == NULL) 758 if (buf == NULL)
754 goto error; 759 goto error;
755 760
756 if (!Py_UnbufferedStdioFlag) { 761 if (buffering) {
757 raw = PyObject_GetAttrString(buf, "raw"); 762 raw = PyObject_GetAttrString(buf, "raw");
758 if (raw == NULL) 763 if (raw == NULL)
759 goto error; 764 goto error;
760 } 765 }
761 else { 766 else {