From: Martin v. Löwis Date: Thu, 27 Jan 2005 18:55:06 +0000 (+0000) Subject: Partially revert #1074011; don't try to fflush stdin. X-Git-Tag: v2.3.5~15 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f3377e42e30999a47dbca0395f986a45b157e090;p=thirdparty%2FPython%2Fcpython.git Partially revert #1074011; don't try to fflush stdin. --- diff --git a/Misc/NEWS b/Misc/NEWS index 910e05c87b34..24af10ae4702 100644 --- 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? ============================== diff --git a/Python/sysmodule.c b/Python/sysmodule.c index ed1dd9e1c108..a87cd18df62c 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -916,7 +916,16 @@ _PySys_Init(void) m = Py_InitModule3("sys", sys_methods, sys_doc); sysdict = PyModule_GetDict(m); - sysin = PyFile_FromFile(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, "", "r", NULL); sysout = PyFile_FromFile(stdout, "", "w", _check_and_flush); syserr = PyFile_FromFile(stderr, "", "w", _check_and_flush); if (PyErr_Occurred())