Author Drekin
Recipients David.Sankel, Drekin, akira, amaury.forgeotdarc, christian.heimes, christoph, davidsarah, ezio.melotti, giampaolo.rodola, hippietrail, lemburg, mark, mhammond, pitrou, santoso.wijaya, smerlin, ssbarnea, terry.reedy, tim.golden, tzot, v+python, vstinner
Date 2012-09-21.16:20:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Hello, I'm trying to handle Unicode input and output in Windows console and found this issue. Will this be solved in 3.3 final? I tried to write a solution (file attached) based on solution here – rewriting sys.stdin and sys.stdout so it uses ReadConsoleW and WriteConsoleW.

Output works well, but there are few problems with input. First, the Python interactive interpreter actually doesn't use sys.stdin but standard C stdin. It's implemented over file pointer (PyRun_InteractiveLoopFlags, PyRun_InteractiveOneFlags in pythonrun). But still the interpreter uses sys.stdin.encoding (assigning sys.stdin something, that doesn't have encoding==None freezes the interpreter). Wouldn't it make more sense if it used sys.__stdin__.encoding?

However, input() (which uses stdin.readline) works as expected. There's a small problem with KeyboardInterrupt. Since signals are processed asynchronously, it's raised at random place and it behaves wierdly. time.sleep(0.01) after the C call works well, but it's an ugly solution.

When code.interact() is used instead of standard interpreter, it works as expected. Is there a way of changing the intepreter loop? Some hook which calls code.interact() at the right place? The patch can be applied in site or sitecustomized, but calling code.iteract() there obviously doesn't work.

Some other remarks:
- When sys.stdin or sys.stdout doesn't define encoding and errors, input() raises TypeError: bad argument type for built-in operation.
- input() raises KeyboardInterrupt on Ctrl-C in Python 3.2 but not in Python 3.3rc2.
Date User Action Args
2012-09-21 16:20:09Drekinsetrecipients: + Drekin, lemburg, mhammond, terry.reedy, tzot, amaury.forgeotdarc, pitrou, vstinner, giampaolo.rodola, christian.heimes, tim.golden, mark, christoph, ezio.melotti, v+python, hippietrail, ssbarnea, davidsarah, santoso.wijaya, akira, David.Sankel, smerlin
2012-09-21 16:20:09Drekinsetmessageid: <>
2012-09-21 16:20:08Drekinlinkissue1602 messages
2012-09-21 16:20:07Drekincreate