summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-04-03 10:56:49 +0000
committerMartin v. Löwis <martin@v.loewis.de>2006-04-03 10:56:49 +0000
commit22ec30d607b86bd681f30382e3ce17005f65e5c3 (patch)
treea8716133591c547eb1c381340892d9805243e40a /Python/pythonrun.c
parentf615a3a2fd6cfb88fd4f886525bc6e2eb7369d26 (diff)
downloadcpython-22ec30d607b86bd681f30382e3ce17005f65e5c3.tar.gz
Bug #1421664: Set sys.stderr.encoding
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 4c8c5176e5..1aa6930435 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -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