diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-21 23:45:42 +0000 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-21 23:45:42 +0000 |
commit | 17b0f141ce9882104863d5a7914759a43843de29 (patch) | |
tree | 4ce9f5dcb40477ad3ec552bc2e6ae3c035e20cb0 /Python/pythonrun.c | |
parent | 585c5e82acbb4003d5d66919ea5fda7d177624c2 (diff) | |
download | cpython-17b0f141ce9882104863d5a7914759a43843de29.tar.gz |
Issue #3798: sys.exit(message) writes the message to sys.stderr file, instead
of the C file stderr, to use stderr encoding and error handler
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index b469c4a625..1581c90fb3 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1386,10 +1386,12 @@ handle_system_exit(void) 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); + 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; } |