From ea62d2535f6160d5b4306ea060f5da05cfa7e9ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Mon, 3 Apr 2006 10:56:49 +0000 Subject: Bug #1421664: Set sys.stderr.encoding --- Python/pythonrun.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Python/pythonrun.c') 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 -- cgit v1.2.1