Author Drekin
Recipients David.Sankel, Drekin, akira, amaury.forgeotdarc, christian.heimes, christoph, davidsarah, ezio.melotti, giampaolo.rodola, haypo, hippietrail, lemburg, mark, mhammond, pitrou, santoso.wijaya, smerlin, sorin, terry.reedy, tim.golden, tzot, v+python
Date 2013-03-24.13:02:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1364130145.6.0.558707071045.issue1602@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-03-24 13:02:25Drekinsetrecipients: + Drekin, lemburg, mhammond, terry.reedy, tzot, amaury.forgeotdarc, pitrou, haypo, giampaolo.rodola, christian.heimes, tim.golden, mark, christoph, ezio.melotti, v+python, hippietrail, sorin, davidsarah, santoso.wijaya, akira, David.Sankel, smerlin
2013-03-24 13:02:25Drekinsetmessageid: <1364130145.6.0.558707071045.issue1602@psf.upfronthosting.co.za>
2013-03-24 13:02:25Drekinlinkissue1602 messages
2013-03-24 13:02:25Drekincreate