Mercurial > cpython-lru_cache-weakref
diff Python/sysmodule.c @ 34511:91038801eb45 2.4
Partially revert #1074011; don't try to fflush stdin.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Thu, 27 Jan 2005 18:58:30 +0000 |
| parents | 4a1fefdfc793 |
| children | 35c43674083a |
line wrap: on
line diff
--- a/Python/sysmodule.c Wed Jan 26 22:46:26 2005 +0000 +++ b/Python/sysmodule.c Thu Jan 27 18:58:30 2005 +0000 @@ -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())
