diff options
| author | Martin v. Löwis <martin@v.loewis.de> | 2005-01-27 18:55:06 (GMT) |
|---|---|---|
| committer | Martin v. Löwis <martin@v.loewis.de> | 2005-01-27 18:55:06 (GMT) |
| commit | f3377e42e30999a47dbca0395f986a45b157e090 (patch) | |
| tree | 70bd3b1cf4345a14142e6d4bfa2e85f56f3322fe /Python/sysmodule.c | |
| parent | 4ac0fc8c3b11a4b760159f9f87661824b20958aa (diff) | |
| download | cpython-f3377e42e30999a47dbca0395f986a45b157e090.zip cpython-f3377e42e30999a47dbca0395f986a45b157e090.tar.gz cpython-f3377e42e30999a47dbca0395f986a45b157e090.tar.bz2 | |
Partially revert #1074011; don't try to fflush stdin.
Diffstat (limited to 'Python/sysmodule.c')
| -rw-r--r-- | Python/sysmodule.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index ed1dd9e..a87cd18 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, "<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()) |
