[Python-checkins] python/dist/src/Python sysmodule.c,2.127,2.128
loewis at users.sourceforge.net
loewis at users.sourceforge.net
Thu Jan 27 19:56:19 CET 2005
Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22685/Python
Modified Files:
sysmodule.c
Log Message:
Partially revert #1074011; don't try to fflush stdin.
Backported to 2.3 and 2.4.
Index: sysmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v
retrieving revision 2.127
retrieving revision 2.128
diff -u -d -r2.127 -r2.128
--- sysmodule.c 23 Jan 2005 09:41:49 -0000 2.127
+++ sysmodule.c 27 Jan 2005 18:56:16 -0000 2.128
@@ -947,7 +947,16 @@
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())
More information about the Python-checkins
mailing list