mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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).
This commit is contained in:
parent
372ac5e732
commit
e9fb319e68
2 changed files with 22 additions and 8 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue