Martin von Löwis committed 6f2dd08

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

Comments (0)

Files changed (2)

 (editors: check 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?


 	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())
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.