Adam Bartoš added the comment:

I really don't know how stdio in console in Linux works. In my package 
https://github.com/Drekin/win-unicode-console I set custom sys.std* streams and 
a custom readline hook to support Unicode in Python run in Windows console. If 
I run `py` with my fixes enabled, >>> "α" really yields "α", but when I run `py 
-i > output.txt`, >>> "α" yields "?" (written to the file of course) same as 
when my fixes are disabled. From this point of view it seemed wrong that 
redirection of output affects how a line is read.

Regarding the prompt, I think it should be always written to sys.stdout, so we 
may hypothetically add a wrapper around GNU readline writing the prompt to 
sys.stdout and calling the actual readline with empty prompt.

So you are telling me that the characters displayed in console when entering 
input are actually written to stdout in Linux (I think it's not the case in 
Windows)? Maybe it woudn't matter if they were written to console even when 
stdout is redirected.

I'm not saying it is extra useful to redirect stdout while providing 
interactive input, I was just wondering what should be the right behavior. And 
from my point of view motivated as explained above, readlinehook should be used 
even with redirected stdout, at least in Windows.

----------

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

Reply via email to