Drekin added the comment:

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.

----------
nosy: +Drekin
Added file: http://bugs.python.org/file27245/win_unicode_console.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue1602>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to