[issue1927] raw_input behavior incorrect if readline not enabled

Martin Panter report at bugs.python.org
Sat Dec 5 03:12:40 EST 2015


Martin Panter added the comment:

Here is an updated patch for Python 3.

I did not remove the “lost sys.stderr” check I mentioned earlier, because the implementation still needs it to call flush().

Changes compared to Michael’s patch:

* Added a test for input() using a pseudoterminal and subprocess.Popen
* Write to the passed-in sys_stdout parameter, not the global stdout
* Continue to call fflush(stderr), to avoid regressions with buffered stderr messages
* Updated /Parser/pgenmain.c to use sys_stdout

I also had to update test_cmd_line_script, which expected the prompt to be on stderr. This made me wonder if it is a good idea to change where the interpreter prompt (>>>) goes in a bugfix release. AFAIK it is not documented, and it could potentially break other things that use the interactive interpreter. What do people think? A way to avoid this might be to pass stderr as the sys_stdout parameter.

Also, it would be awesome if someone could try my new test_builtins test case on BSD or OS X. I only tested it with Linux. The last time I messed with pseudoterminals like this I caused the tests to hang on BSD buildbots.

----------
stage: test needed -> patch review
Added file: http://bugs.python.org/file41246/promptOutputFix3.v2.patch

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


More information about the Python-bugs-list mailing list