This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author agthorr
Recipients
Date 2002-02-04.21:42:13
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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
History
Date User Action Args
2007-08-23 15:10:51adminlinkissue512981 messages
2007-08-23 15:10:51admincreate