summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-05-21 23:45:42 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-05-21 23:45:42 (GMT)
commit7126dbc867e99e675ed29037c6b10681dbaa8dc9 (patch)
treeba594287cd7379500874f5d73c1bc4daed133428 /Python
parent3df439d1a055f616345fe4128c897a9c27c7b671 (diff)
downloadcpython-7126dbc867e99e675ed29037c6b10681dbaa8dc9.zip
cpython-7126dbc867e99e675ed29037c6b10681dbaa8dc9.tar.gz
cpython-7126dbc867e99e675ed29037c6b10681dbaa8dc9.tar.bz2
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')
-rw-r--r--Python/pythonrun.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index b469c4a..1581c90 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;
}