Martin v. Löwis <mar...@v.loewis.de> added the comment: > but why it is forced to encoded to utf-8, > I think it should be encoded by the locale related encodings,not always utf-8, > for example,in GBK locale,it should use GBK to encode the unicode > object,right?
Wrong. Exec'ing Unicode strings has been specified to encode all strings as UTF-8. This cannot be changed anymore. Even if this was possible to change, it should *not* use the locale encoding. The source encoding and the locale encoding are independent; the source encoding is normally determined from PEP 263 declarations. So if anything, exec'ing Unicode strings should use an encoding declaration that you have in that string. However, you don't have one, and they are unsupported for Unicode strings, anyway. ---------- title: exec encode unicode to utf-8 str automatically in GBK environment -> exec encode unicode to utf-8 str automatically in GBK environment _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue10187> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com