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,7 +10,7 @@ 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
13+ - Bug #1074011: closing sys.std{out,err} now causes a flush() and
1414 an ferror() call.
1515
1616- min() and max() now support key= arguments with the same meaning as in
Original file line number Diff line number Diff line change @@ -947,7 +947,16 @@ _PySys_Init(void)
947947 m = Py_InitModule3 ("sys" , sys_methods , sys_doc );
948948 sysdict = PyModule_GetDict (m );
949949
950- sysin = PyFile_FromFile (stdin , "<stdin>" , "r" , _check_and_flush );
950+ /* Closing the standard FILE* if sys.std* goes aways causes problems
951+ * for embedded Python usages. Closing them when somebody explicitly
952+ * invokes .close() might be possible, but the FAQ promises they get
953+ * never closed. However, we still need to get write errors when
954+ * writing fails (e.g. because stdout is redirected), so we flush the
955+ * streams and check for errors before the file objects are deleted.
956+ * On OS X, fflush()ing stdin causes an error, so we exempt stdin
957+ * from that procedure.
958+ */
959+ sysin = PyFile_FromFile (stdin , "<stdin>" , "r" , NULL );
951960 sysout = PyFile_FromFile (stdout , "<stdout>" , "w" , _check_and_flush );
952961 syserr = PyFile_FromFile (stderr , "<stderr>" , "w" , _check_and_flush );
953962 if (PyErr_Occurred ())
You can’t perform that action at this time.
0 commit comments