Issue 1333679: Allow use of non-latin1 chars in interactive shell (original) (raw)

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

Logged In: YES user_id=21627

No, IOBindings.encoding is not hard coded 'latin1'. It is locale.getdefaultlocale()[1] on Windows, and locale.nl_langinfo(locale.CODESET) on Unix. If these fail, it is 'ascii'.