[issue10187] exec encode unicode to utf-8 str automatically in GBK environment

Martin v. Löwis report at bugs.python.org
Sun Oct 24 08:55:56 CEST 2010


Martin v. Löwis <martin at 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 <report at bugs.python.org>
<http://bugs.python.org/issue10187>
_______________________________________


More information about the Python-bugs-list mailing list