comparison 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
comparison
equal deleted inserted replaced
34508:13176ed52e65 34511:91038801eb45
945 #endif 945 #endif
946 946
947 m = Py_InitModule3("sys", sys_methods, sys_doc); 947 m = Py_InitModule3("sys", sys_methods, sys_doc);
948 sysdict = PyModule_GetDict(m); 948 sysdict = PyModule_GetDict(m);
949 949
950 sysin = PyFile_FromFile(stdin, "<stdin>", "r", _check_and_flush); 950 /* Closing the standard FILE* if sys.std* goes aways causes problems
951 * for embedded Python usages. Closing them when somebody explicitly
952 * invokes .close() might be possible, but the FAQ promises they get
953 * never closed. However, we still need to get write errors when
954 * writing fails (e.g. because stdout is redirected), so we flush the
955 * streams and check for errors before the file objects are deleted.
956 * On OS X, fflush()ing stdin causes an error, so we exempt stdin
957 * from that procedure.
958 */
959 sysin = PyFile_FromFile(stdin, "<stdin>", "r", NULL);
951 sysout = PyFile_FromFile(stdout, "<stdout>", "w", _check_and_flush); 960 sysout = PyFile_FromFile(stdout, "<stdout>", "w", _check_and_flush);
952 syserr = PyFile_FromFile(stderr, "<stderr>", "w", _check_and_flush); 961 syserr = PyFile_FromFile(stderr, "<stderr>", "w", _check_and_flush);
953 if (PyErr_Occurred()) 962 if (PyErr_Occurred())
954 return NULL; 963 return NULL;
955 #ifdef MS_WINDOWS 964 #ifdef MS_WINDOWS