mirror of
https://github.com/python/cpython.git
synced 2025-07-26 20:54:39 +00:00
Bug #1421664: Set sys.stderr.encoding
This commit is contained in:
parent
cf0a2a8576
commit
ea62d2535f
3 changed files with 18 additions and 0 deletions
|
@ -281,6 +281,16 @@ Py_InitializeEx(int install_sigs)
|
|||
}
|
||||
Py_XDECREF(sys_isatty);
|
||||
|
||||
sys_stream = PySys_GetObject("stderr");
|
||||
sys_isatty = PyObject_CallMethod(sys_stream, "isatty", "");
|
||||
if (!sys_isatty)
|
||||
PyErr_Clear();
|
||||
if(sys_isatty && PyObject_IsTrue(sys_isatty)) {
|
||||
if (!PyFile_SetEncoding(sys_stream, codeset))
|
||||
Py_FatalError("Cannot set codeset of stderr");
|
||||
}
|
||||
Py_XDECREF(sys_isatty);
|
||||
|
||||
if (!Py_FileSystemDefaultEncoding)
|
||||
Py_FileSystemDefaultEncoding = codeset;
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue