Martin Panter added the comment:

The input() implementation is a bit like this:

def input(prompt):
    if stdin and stdout are the original file descriptors, and are terminals:
        return PyOS_Readline(sys.stdin, sys.stdout, prompt)
    else:
        sys.stdout.write(prompt)  # Writes to stdout
        return sys.stdin.readline()

def PyOS_StdioReadline(stdin, stdout, prompt):
    '''Default implementation of PyOS_Readline()'''
    sys.stderr.write(prompt)  # Writes to stderr
    return stdin.readline()

def call_readline(stdin, stdout, prompt):
    '''Implementation of PyOS_Readline() in the "readline" module'''
    rl_instream = stdin
    rl_outstream = stdout  # Readline writes to stdout
    return readline_until_enter_or_signal(prompt)

It looks like PyOS_StdioReadline() has always written to stderr. The stdin and 
stdout parameters of PyOS_Readline() were added later, in revision dc4a0336a2a3.

I think the changes to myreadline.c will also affect the interactive 
interpreter prompt. But we have Issue 12869 open to change that to stdout, so 
maybe the change is okay.

Since input() should no longer depend on any instance of stderr, perhaps the 
check for “lost sys.stderr” should also be removed.

It may be worth applying any changes in myreadline.c to the independent version 
in pgenmain.c as well, just for consistency.

----------

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

Reply via email to