Author martin.panter
Recipients Daniel.Gonzalez, bhuvan, eric.araujo, ezio.melotti, ggenellina, martin.panter, mdomingues, taleinat
Date 2015-11-22.01:13:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1448154802.14.0.173223712782.issue1927@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-11-22 01:13:22martin.pantersetrecipients: + martin.panter, ggenellina, taleinat, ezio.melotti, eric.araujo, mdomingues, Daniel.Gonzalez, bhuvan
2015-11-22 01:13:22martin.pantersetmessageid: <1448154802.14.0.173223712782.issue1927@psf.upfronthosting.co.za>
2015-11-22 01:13:22martin.panterlinkissue1927 messages
2015-11-22 01:13:21martin.pantercreate