[issue17348] Unicode - encoding seems to be lost for inputs of unicode chars in IDLE

Ned Deily report at bugs.python.org
Mon Apr 22 06:41:51 CEST 2013


Ned Deily added the comment:

I think this is another case where confusion is introduced by the behavior of Python 2 interactive mode with regard to encodings.  In 2.x Python/pythonrun.c, depending on a number of factors the interactive loop will try to set a more useful encoding on stdin, stdout, and stderr for any of them assigned to a terminal (isatty)  This is why the examples using the interpreter (not IDLE) work when the locale env variables (LANG, et al) are set to one that supports Unicode (like "en_US.utf8").  If you changed them to a non-Unicode locale (like "C") and ran the interpreter examples, they wouldn't work.  Even clearer, if you used a Unicode-aware text editor to write the examples to files without a  # -*- coding: utf-8 -*- directive and tried to run them with /usr/bin/python2.7, you'd get a syntax error.  I suspect the issue here is that 2.x IDLE PyShell does not exactly mimic the behavior of the interpreter interactive loop about setting encodings for std*.  A side issue is the limitation of Tk's support of non-BMP characters; because of that, it may not possible to fully mimic the interactive interpreter.

----------
nosy: +ned.deily

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17348>
_______________________________________


More information about the Python-bugs-list mailing list