[issue12869] PyOS_StdioReadline is printing the prompt on stderr

Martin Panter report at bugs.python.org
Tue Aug 4 06:30:06 CEST 2015


Martin Panter added the comment:

Results of experimenting on 3.6:

* The startup messages are written to standard error.
* The interactive interpreter prompts to the original standard error if Readline not used. But with Gnu Readline, prompts do go to the original standard output, as does other interactive Readline output (echoed input etc). This is what Albert reported.
* The interactive interpreter always reads from the original standard input, whether Readline is used or not.
* The displayhook() function always writes to the current sys.stdout, as documented.
* The excepthook() function always writes to the current sys.stderr, also as documented.
* The input() function is documented to prompt to sys.stdout, however see Issue 1927 for some quirks with that.
* The input() function always reads from the current sys.stdin. The Readline library is only used if sys.stdin and sys.stdout are the original file descriptors.

I agree it would probably be more consistent for the interpreter prompt to go to standard output. It looks like stdout is inspected to determine whether Readline will be used, while stderr is not inspected. So it makes sense for the prompt to go to stdout.

However I disagree that it should go to a redirected stream, sys.stderr or sys.stdout, since sys.stdin does not affect input. But see Issue 17620, about redirecting sys.stdin.

----------
nosy: +vadmium
versions: +Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12869>
_______________________________________


More information about the Python-bugs-list mailing list