File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ What's New in Python 2.5 alpha 1?
1010Core and builtins
1111-----------------
1212
13+ - Bug #1074011: closing sys.std{in,out,err} now causes a flush() and
14+ an ferror() call.
15+
1316- min() and max() now support key= arguments with the same meaning as in
1417 list.sort().
1518
Original file line number Diff line number Diff line change @@ -927,6 +927,13 @@ settrace() -- set the global debug tracing function\n\
927927)
928928/* end of sys_doc */ ;
929929
930+ static int
931+ _check_and_flush (FILE * stream )
932+ {
933+ int prev_fail = ferror (stream );
934+ return fflush (stream ) || prev_fail ? EOF : 0 ;
935+ }
936+
930937PyObject *
931938_PySys_Init (void )
932939{
@@ -940,9 +947,9 @@ _PySys_Init(void)
940947 m = Py_InitModule3 ("sys" , sys_methods , sys_doc );
941948 sysdict = PyModule_GetDict (m );
942949
943- sysin = PyFile_FromFile (stdin , "<stdin>" , "r" , NULL );
944- sysout = PyFile_FromFile (stdout , "<stdout>" , "w" , NULL );
945- syserr = PyFile_FromFile (stderr , "<stderr>" , "w" , NULL );
950+ sysin = PyFile_FromFile (stdin , "<stdin>" , "r" , _check_and_flush );
951+ sysout = PyFile_FromFile (stdout , "<stdout>" , "w" , _check_and_flush );
952+ syserr = PyFile_FromFile (stderr , "<stderr>" , "w" , _check_and_flush );
946953 if (PyErr_Occurred ())
947954 return NULL ;
948955#ifdef MS_WINDOWS
You can’t perform that action at this time.
0 commit comments