diff options
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index f203618..db5d0a7 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1106,7 +1106,13 @@ handle_system_exit(void) if (PyInt_Check(value)) exitcode = (int)PyInt_AsLong(value); else { - PyObject_Print(value, stderr, Py_PRINT_RAW); + PyObject *sys_stderr = PySys_GetObject("stderr"); + if (sys_stderr != NULL && sys_stderr != Py_None) { + PyFile_WriteObject(value, sys_stderr, Py_PRINT_RAW); + } else { + PyObject_Print(value, stderr, Py_PRINT_RAW); + fflush(stderr); + } PySys_WriteStderr("\n"); exitcode = 1; } |