Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 61920:bd5f5df7ed78 legacy-trunk
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
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Tue, 25 May 2010 22:30:32 +0000 |
| parents | fd25030223b0 |
| children | 55397533da51 |
comparison
equal
deleted
inserted
replaced
| 61914:f1337fe6b7b7 | 61920:bd5f5df7ed78 |
|---|---|
| 1104 just let the else clause below print the error. */ | 1104 just let the else clause below print the error. */ |
| 1105 } | 1105 } |
| 1106 if (PyInt_Check(value)) | 1106 if (PyInt_Check(value)) |
| 1107 exitcode = (int)PyInt_AsLong(value); | 1107 exitcode = (int)PyInt_AsLong(value); |
| 1108 else { | 1108 else { |
| 1109 PyObject_Print(value, stderr, Py_PRINT_RAW); | 1109 PyObject *sys_stderr = PySys_GetObject("stderr"); |
| 1110 if (sys_stderr != NULL && sys_stderr != Py_None) { | |
| 1111 PyFile_WriteObject(value, sys_stderr, Py_PRINT_RAW); | |
| 1112 } else { | |
| 1113 PyObject_Print(value, stderr, Py_PRINT_RAW); | |
| 1114 fflush(stderr); | |
| 1115 } | |
| 1110 PySys_WriteStderr("\n"); | 1116 PySys_WriteStderr("\n"); |
| 1111 exitcode = 1; | 1117 exitcode = 1; |
| 1112 } | 1118 } |
| 1113 done: | 1119 done: |
| 1114 /* Restore and clear the exception info, in order to properly decref | 1120 /* Restore and clear the exception info, in order to properly decref |
