File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ What's New in Python 2.5 alpha 1?
1212Core and builtins
1313-----------------
1414
15+ - Bug #1421664: sys.stderr.encoding is now set to the same value as
16+ sys.stdout.encoding.
17+
1518- __import__ accepts keyword arguments.
1619
1720- Patch #1460496: round() now accepts keyword arguments.
Original file line number Diff line number Diff line change @@ -281,6 +281,16 @@ Py_InitializeEx(int install_sigs)
281281 }
282282 Py_XDECREF (sys_isatty );
283283
284+ sys_stream = PySys_GetObject ("stderr" );
285+ sys_isatty = PyObject_CallMethod (sys_stream , "isatty" , "" );
286+ if (!sys_isatty )
287+ PyErr_Clear ();
288+ if (sys_isatty && PyObject_IsTrue (sys_isatty )) {
289+ if (!PyFile_SetEncoding (sys_stream , codeset ))
290+ Py_FatalError ("Cannot set codeset of stderr" );
291+ }
292+ Py_XDECREF (sys_isatty );
293+
284294 if (!Py_FileSystemDefaultEncoding )
285295 Py_FileSystemDefaultEncoding = codeset ;
286296 else
Original file line number Diff line number Diff line change @@ -1069,6 +1069,11 @@ _PySys_Init(void)
10691069 if (!PyFile_SetEncoding (sysout , buf ))
10701070 return NULL ;
10711071 }
1072+ if (isatty (_fileno (stderr ))) {
1073+ sprintf (buf , "cp%d" , GetConsoleOutputCP ());
1074+ if (!PyFile_SetEncoding (syserr , buf ))
1075+ return NULL ;
1076+ }
10721077#endif
10731078
10741079 PyDict_SetItemString (sysdict , "stdin" , sysin );
You can’t perform that action at this time.
0 commit comments