]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Partially revert #1074011; don't try to fflush stdin.
authorMartin v. Löwis <martin@v.loewis.de>
Thu, 27 Jan 2005 18:55:06 +0000 (18:55 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Thu, 27 Jan 2005 18:55:06 +0000 (18:55 +0000)
Misc/NEWS
Python/sysmodule.c

index 910e05c87b34e5dcba764613e72e0a83718d2de4..24af10ae47026375ca1014bd049e7950d45314e7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -4,6 +4,15 @@ Python News
 
 (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?
 ==============================
 
index ed1dd9e1c108464a7caed24f886edac132d4deac..a87cd18df62c89ad0ddc3a06e8779b5de39e915b 100644 (file)
@@ -916,7 +916,16 @@ _PySys_Init(void)
        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())