summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-04-03 10:56:49 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-04-03 10:56:49 (GMT)
commitea62d2535f6160d5b4306ea060f5da05cfa7e9ab (patch)
treed3ce394a4d53a281d208995811397a247bb764d6 /Python/pythonrun.c
parentcf0a2a8576b4780263cfeb96d081eea06a1ebe92 (diff)
downloadcpython-ea62d2535f6160d5b4306ea060f5da05cfa7e9ab.zip
cpython-ea62d2535f6160d5b4306ea060f5da05cfa7e9ab.tar.gz
cpython-ea62d2535f6160d5b4306ea060f5da05cfa7e9ab.tar.bz2
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 4c8c517..1aa6930 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