Commits

Martin von Löwis  committed 6f2dd08

Partially revert #1074011; don't try to fflush stdin.

  • Participants
  • Parent commits 2639b10
  • Branches 2.3

Comments (0)

Files changed (2)

 
 (editors: check NEWS.help for information about editing NEWS using ReST.)
 
+What's New in Python 2.3.5?
+==============================
+
+*Release date: XX-XXX-2005*
+
+Core and builtins
+-----------------
+- Partially revert the fix for #1074011; don't try to fflush stdin anymore.
+
 What's New in Python 2.3.5rc1?
 ==============================
 

File Python/sysmodule.c

 	m = Py_InitModule3("sys", sys_methods, sys_doc);
 	sysdict = PyModule_GetDict(m);
 
-	sysin = PyFile_FromFile(stdin, "<stdin>", "r", _check_and_flush);
+	/* Closing the standard FILE* if sys.std* goes aways causes problems
+	 * for embedded Python usages. Closing them when somebody explicitly
+	 * invokes .close() might be possible, but the FAQ promises they get
+	 * never closed. However, we still need to get write errors when
+	 * writing fails (e.g. because stdout is redirected), so we flush the
+	 * streams and check for errors before the file objects are deleted.
+	 * On OS X, fflush()ing stdin causes an error, so we exempt stdin
+	 * from that procedure.
+	 */
+	sysin = PyFile_FromFile(stdin, "<stdin>", "r", NULL);
 	sysout = PyFile_FromFile(stdout, "<stdout>", "w", _check_and_flush);
 	syserr = PyFile_FromFile(stderr, "<stderr>", "w", _check_and_flush);
 	if (PyErr_Occurred())