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.

Author methane
Recipients ajaksu2, kbk, methane, sgala
Date 2009-04-12.00:45:53
SpamBayes Score 0.00020132744
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:55methanesetrecipients: + methane, kbk, sgala, ajaksu2
2009-04-12 00:45:54methanesetmessageid: <1239497154.87.0.635159253865.issue1542677@psf.upfronthosting.co.za>
2009-04-12 00:45:54methanelinkissue1542677 messages
2009-04-12 00:45:53methanecreate