summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-05-25 22:40:38 +0000
committerVictor Stinner <victor.stinner@haypocalc.com>2010-05-25 22:40:38 +0000
commitc3e40e0454de9c6f3e46f8a6e3409b5975835af9 (patch)
tree389885f1de22df4c98e62285c73aa9911e520958 /Python
parent7620f66397fbbd49ed4894a80de3d56356e6273e (diff)
downloadcpython-git-c3e40e0454de9c6f3e46f8a6e3409b5975835af9.tar.gz
Merged revisions 81537 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81537 | victor.stinner | 2010-05-26 00:30:32 +0200 (mer., 26 mai 2010) | 3 lines Issue #3798: Write sys.exit() message to sys.stderr to use stderr encoding and error handler, instead of writing to the C stderr file in utf-8 ........
Diffstat (limited to 'Python')
-rw-r--r--Python/pythonrun.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 0ab7165e2f..1a7e01ee4d 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1111,7 +1111,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;
}