This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 piro
收信人 piro
日期 2010-07-05.16:07:51
SpamBayes Score 4.9936698e-05
Marked as misclassified
Message-id <1278346074.17.0.914375109611.issue9167@psf.upfronthosting.co.za>
In-reply-to
内容
Looks like the wchar_t* array returned by Py_GetArgcArgv() on OSX suffers by double encoding. This can affect sys.argv, sys.executable and C code relying on the above function of course.

On Linux:

$ python3
Python 3.0rc1+ (py3k, Oct 28 2008, 09:22:29) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, sys
>>> snowman = '\u2603'
>>> os.system(sys.executable + " -c 'import sys; [print(a.encode(\"utf8\")) for a in sys.argv]' foo bar " + snowman)
b'-c'
b'foo'
b'bar'
b'\xe2\x98\x83'
0

On OSX (uname -a is Darwin comicbookguy.local 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386)

$ python3
Python 3.1.2 (r312:79147, Jul  5 2010, 11:57:14) 
[GCC 4.2.1 (Apple Inc. build 5659)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, sys
>>> snowman = '\u2603'
>>> os.system(sys.executable + " -c 'import sys; [print(a.encode(\"utf8\")) for a in sys.argv]' foo bar " + snowman)
b'-c'
b'foo'
b'bar'
b'\xc3\xa2\xc2\x98\xc2\x83'
0

Is this a known limitation of the platform? I don't know much about OSX, just found it testing for regressions in setproctitle <http://code.google.com/p/py-setproctitle/>

Reported correctly working on Windows.
历史
日期 用户 动作 参数
2010-07-05 16:07:58piro修改recipients: + piro
2010-07-05 16:07:54piro修改messageid: <1278346074.17.0.914375109611.issue9167@psf.upfronthosting.co.za>
2010-07-05 16:07:52piro链接issue9167 messages
2010-07-05 16:07:51piro创建