mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
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
This commit is contained in:
parent
3df439d1a0
commit
7126dbc867
3 changed files with 19 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue