If I type a unicode string, such as u"éÜÕÝ" in the
interactive interpreter in the terminal, it does what I
expect - return the unicode string (in this case,
u'\u05e9\u05dc\u05d5\u05dd')
However, if I type it in IDLE's interactive
interpreter, I get something funny - I get a unicode
string (u'\xd7\xa9\xd7\x9c\xd7\x95\xd7\x9d'), which is
actually u"éÜÕÝ".decode('utf8').encode('latin1').
This is caused by the PyShell.runsource method, which
checks if the source string it gets is unicode, and if
so, encodes it using the 'ascii' codec. If this check
is removed, so that the unicode object itself gets
compiled, everything works out fine.
The bottom line: remove the if block starting with "if
isinstance(source, types.UnicodeType)", at
PyShell.py:589, and everything is fine.
Have a good day,
Noam
|