Message13010
While running our projects acceptance tests with Jython 2.7.2rc1 we noticed that the value of `sys.stdout.encoding` is different to what it was with earlier versions if using Windows, the current code page is different to the default code page, and stdout is redirected.
For example, on my Windows machine the default code page is 850 and by default the output of both of these commands is cp850:
jython -c "import sys; print sys.stdout.encoding"
jython -c "import sys; print sys.stdout.encoding" > out.txt
If I change the code page to 437 with `chcp 437`, then the first command above correctly prints cp437 but output of the latter is cp850. With earlier Jython versions the result was cp437 in both cases.
It seems that when output is redirected, `sys.stdout.encoding` always returns the system wide code page when it should return the code page the console is using. We actually had a similar bug in our code base and there the problem was that we used Windows API function GetOEMCP when we should have used GetConsoleOutputCP. |
|
Date |
User |
Action |
Args |
2020-03-10 23:36:24 | pekka.klarck | set | recipients:
+ pekka.klarck |
2020-03-10 23:36:24 | pekka.klarck | set | messageid: <1583883384.67.0.817252048432.issue2868@roundup.psfhosted.org> |
2020-03-10 23:36:24 | pekka.klarck | link | issue2868 messages |
2020-03-10 23:36:24 | pekka.klarck | create | |
|