summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-05-17 08:58:51 +0000
committerVictor Stinner <victor.stinner@haypocalc.com>2010-05-17 08:58:51 +0000
commit737239f6f90fe530a0e75462a3bf6b4679abe49f (patch)
treef48cfe6400e4dcd1690df2bbd8b3202a932dc193 /Python/pythonrun.c
parent66046bbcf9c795d76c75dcb5d518305d2f0c957c (diff)
downloadcpython-737239f6f90fe530a0e75462a3bf6b4679abe49f.tar.gz
handle_system_exit() flushs files to warranty the output order
PyObject_Print() writes into the C object stderr, whereas PySys_WriteStderr() writes into the Python object sys.stderr. Each object has its own buffer, so call sys.stderr.flush() and fflush(stderr).
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 4932c4ad4c..d3981961ee 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1367,7 +1367,11 @@ handle_system_exit(void)
if (PyLong_Check(value))
exitcode = (int)PyLong_AsLong(value);
else {
+ PyObject *sys_stderr = PySys_GetObject("stderr");
+ if (sys_stderr != NULL)
+ PyObject_CallMethod(sys_stderr, "flush", NULL);
PyObject_Print(value, stderr, Py_PRINT_RAW);
+ fflush(stderr);
PySys_WriteStderr("\n");
exitcode = 1;
}