(Sorry for posting twice, forgot to add the list to Cc.)
On Tue, Nov 19, 2013 at 6:08 PM, firstname.lastname@example.org wrote:
On Tue, Nov 19, 2013, at 4:46, email@example.com wrote:
I really wanted to be able to write Unicode in Windows console, so I have written the following code: http://bugs.python.org/file31756/streams.py (based on other samples of code I found), in connection with http://bugs.python.org/issue1602 . It addresses the design of using as much as possible from io hierarchy. It definitely doesn't cover many details but I actually use it in my interactive console.
For this whole tactic of "using as much as possible from the io hierarchy" and acting like a raw stream that reads UTF-16 bytes, I'm worried that at some point it's going to run into something that tries to read a single byte - to which your code will return 0.
Well, if you use the textio object than there are no problems and you couldn't use buffered or raw io at all with the other approach. If you try to read one byte from raw io, it just returns b''. More serious problems occur with buffered io if you somehow get a buffer of odd length. In that case flush call ends in infinity loop. Some of these could be solved by adding some checking code to buffered io which will raise an exception if you try to do something bad.