Martin Panter added the comment:

In Linux, the original stdin, stdout, stderr file descriptors refer to the same 
console by default, and you use normal file reads and writes on them. In Linux 
when Python uses Gnu Readline, the displayed input characters are indeed 
written to the original stdout file descriptor. For comparison, when Readline 
is not used, the displayed characters go to the original stdin console, because 
they are handled at a lower OS level before they are even read by Python and 
Readline.

By experimentation, the Bash shell seems to work similarly, except it uses 
stderr rather than stdout. You can freely redirect stdout, but if you redirect 
stderr it affects the output seen on the terminal. It may be possible to write 
to stdin to avoid the input and output being split up, but I think writing to 
an input-only file descriptor is a bad idea.

If you dropped the isatty() check for stdout in Linux, you may end up with the 
output of Readline in the file (assuming Readline is okay with this). The file 
would include all the cursor positioning codes, backspaces, etc, that Readline 
generates. But I haven’t actually tried this.

----------

_______________________________________
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