[issue1602] windows console doesn't print or input Unicode

Drekin report at bugs.python.org
Sun Mar 24 14:02:25 CET 2013


Drekin added the comment:

Hello. I have made a small upgrade of the workaround.
• win_unicode_console.enable_streams() sets sys.stdin, stdout and stderr to custom filelike objects which use Windows functions ReadConcoleW and WriteConsoleW to handle unicode data properly. This can be done in sitecustomize.py to take effect automatically.

• Since Python interactive console doesn't use sys.stdin for getting input (still don't know reason for this), there is an alternative repl based on code.interact(). win_unicode_console.IntertactiveConsole.enable() sets it up. To set it up automatically, put the enabling code into a startup file and set PYTHONSTARTUP environment variable. This works for interactive session (just running python with no script).

• Since there is no hook to run InteractiveConsole.enable() when a script is run interactively (-i flag), that is after the script and before the interactive session, I have written a helper script i.py. It just runs given script and then enters an interactive mode using InteractiveConsole. Just put i.py into site-packages and run "py -m i script.py arguments" instead of "py -i script.py arguments".

It's a shame that in the year 2013 one cannot simply run Python console on Windows and enter Unicode characters. I'm not saying it's just Python fault, but there is a workaround on Python side.

----------
versions: +Python 3.4
Added file: http://bugs.python.org/file29563/i.py

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


More information about the Python-bugs-list mailing list