[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:38:43 CEST 2010

Martin v. Löwis <martin at v.loewis.de> added the comment:

This is not a bug, but intentional.

a is a Unicode string; it does not have an encoding internally (not GBK, not UTF-8). Then, the string being exec'ed also becomes a Unicode string. exec'ing Unicode strings is confusing; try to avoid this. The semantics of exec'ing a Unicode string is that all str (but not unicode) literals get encoded as UTF-8.

To see the result you expect, write

a = "麓贸"

nosy: +loewis
resolution:  -> invalid
status: open -> closed

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list