Message38862
GNU readline doesn't work if the C symbol "stdin" is
not a tty, even if the python symbol sys.stdin is.
This will happen, for example, if a program initially
receives input from a pipe, but then changes sys.stdin
to read from /dev/tty. (This is how programs like
"less" work)
Here's a sample program that exhibits this behavior:
------------------------------------------------------------------------
#!/usr/bin/env python
import sys
mail = sys.stdin.read ()
sys.stdin = open ('/dev/tty', 'r')
import readline
foo = raw_input ('add_idea> ')
print foo
------------------------------------------------------------------------
You can test this by saving the above program to a file
(foo.py), piping data to it, then trying to use GNU
readline editing commands at the prompt.
E.g.:
------------------------------------------------------------------------
liberty:~$ cat ideas.html | ./foo.py
add_idea> asdfsdf^Afoo
asdfsdffoo
------------------------------------------------------------------------
The patch attached seems to fix the problem. You may
want to grep the source for other modules that may have
similar bugs. Also, this patch assumes that the
readline module is imported *after* sys.stdin is
changed. This much better than nothing (particularly
if it's documented), but there may be a better solution.
-- Agthorr |
|
Date |
User |
Action |
Args |
2007-08-23 15:10:51 | admin | link | issue512981 messages |
2007-08-23 15:10:51 | admin | create | |
|