mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
Bug #1421664: Set sys.stderr.encoding
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user