Martin v. Löwis <[email protected]> added the comment:
> oh,you mentioned the PEP 263
> but I already set a header like this,you can see the attached test.py
> #coding=GBK
You have that in test.py, but not in the string you are giving to exec.
This is really a separate source code.
So you could have written
exec '''#coding:GBK
print hi('%s')
''' % a
You didn't, hence the code you pass to exec has no declared source encoding.
> why exec choose to use utf-8 not GBK?
exec always choses UTF-8 when exec'ing Unicode strings. The source
encoding of the file that has the exec statement must be irrelevant:
the string being exec'ed may have been received from a different source
file.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue10187>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com