Message286521
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<Enter>"
>>> input("> ") # press "up" key
Re-opening /dev/tty as stdin is a very useful technique. For example, one could debug a script that takes a file as stdin by re-opening the stdin as /dev/tty and using pdb.set_trace().
See bug report for python2 in 2002 here: https://bugs.python.org/issue512981 |
|
Date |
User |
Action |
Args |
2017-01-31 10:53:07 | silvioricardoc | set | recipients:
+ silvioricardoc |
2017-01-31 10:53:07 | silvioricardoc | set | messageid: <1485859987.68.0.026952717617.issue29396@psf.upfronthosting.co.za> |
2017-01-31 10:53:07 | silvioricardoc | link | issue29396 messages |
2017-01-31 10:53:07 | silvioricardoc | create | |
|