Martin Panter added the comment:
I agree it would be good to document when the Readline library is invoked. Yes,
the “readline” module is only designed to work with the original sys.stdin and
sys.stdout. Python’s “open” function does not use FILE objects, but
Python does use FILE objects in
Silvio Ricardo Cordeiro added the comment:
So, if I understood correctly, the `readline` module only works for an
unmodified `sys.stdin`, which is implemented in terms of C `FILE*` structures.
Anything created by `open` will not be implemented in terms of C `FILE*`, and
so all history and comp
Martin Panter added the comment:
I think the difference between Python 2 and 3 here is that Python 2’s file
objects, including sys.stdin, wrap C library FILE objects, which is supported
by the Readline library. However Python 3 has its own kind of file objects,
independent of standard C and Re
New submission from Silvio Ricardo Cordeiro:
The following code works on python2 (tested with 2.7.6), but breaks readline
for python3 (tested with 3.4.3):
>>> import sys, readline
>>> sys.stdin = open('/dev/tty', 'r')
>>> input("> ") # press "7"
>>> input("> ") # press "up" key
Re-opening /d