eval and unicode

"Martin v. Löwis" martin at v.loewis.de
Fri Mar 21 17:01:07 EDT 2008


> eval() somehow decoded the passed expression. No question. It did not 
> use 'ascii', nor 'latin2' but something else. Why is that? Why there is 
> a particular encoding hard coded into eval? Which is that encoding? (I 
> could not decide which one, since '\xdb' will be the same in latin1, 
> latin3, latin4 and probably many others.)

I think in all your examples, you pass a Unicode string to eval, not
a byte string. In that case, it will encode the string as UTF-8, and
then parse the resulting byte string.

Regards,
Martin



More information about the Python-list mailing list