[issue1193] os.system() encoding bug on Windows

Fan Decheng report at bugs.python.org
Mon Sep 24 08:21:50 CEST 2007


Fan Decheng added the comment:

Steps to reproduce:

1. Use a Windows, with system default encoding to cp936 (Chinese PRC, or
Simplified Chinese) in Regional Options.
2. Open Python 3.0 (command line).
3. Type:
import os
import sys
os.system(("echo " + sys.stdin.readline().rstrip("\n")).encode("cp936"))
(in stdin type:)
我

Result:
The output from "echo" would be utf-8 mistakenly used as cp936:
鎴?

Expected result:
The "echo" command outputs "我".

Comments:
I guess os.system can recoding the string before sending the string out.
This may be done in the C part of Python. BTW, The os.popen() function 
is
correct.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1193>
__________________________________


More information about the Python-bugs-list mailing list