Author inada.naoki
Recipients ajaksu2, inada.naoki, kbk, sgala
Date 2009-04-12.00:45:53
SpamBayes Score 0.000201327
Marked as misclassified No
Message-id <1239497154.87.0.635159253865.issue1542677@psf.upfronthosting.co.za>
In-reply-to
Content
This issue is caused by compile() behavior.

Following sample is in codepage 932.

>>> 'あ'
'\x82\xa0'  # OK - 'あ' is '\x82\xa0' in cp932
>>> u'あ'
u'\u3042'   # OK - u'あ' is '\u3042' in UCS-2

compile as byte string.
>>> c = compile("'あ'", 'test', 'single')
>>> exec c
'\x82\xa0'  # OK
>>> c = compile("u'あ'", 'test', 'single')
>>> exec c
u'\x82\xa0' # NG!!!

compile as unicode string.
>>> c = compile(u"'あ'", 'test', 'single')
>>> exec c
'\xe3\x81\x82' # NG!!!
>>> c = compile(u"u'あ'", 'test', 'single')
>>> exec c
u'\u3042'  # OK

compile as byte string with pep 0263
>>> c = compile("# coding: mbcs\n'あ'", 'test', 'single')
>>> exec c
'\x82\xa0' # OK
>>> c = compile("# coding: mbcs\nu'あ'", 'test', 'single')
>>> exec c
u'\u3042'  # OK
History
Date User Action Args
2009-04-12 00:45:55inada.naokisetrecipients: + inada.naoki, kbk, sgala, ajaksu2
2009-04-12 00:45:54inada.naokisetmessageid: <1239497154.87.0.635159253865.issue1542677@psf.upfronthosting.co.za>
2009-04-12 00:45:54inada.naokilinkissue1542677 messages
2009-04-12 00:45:53inada.naokicreate