◐ Shell
clean mode source ↗

Message 38864 - Python tracker

Logged In: YES 
user_id=6324

1) Well, it lets python treat sys.stdin as a tty even if C
stdin != python sys.stdin.  It still checks to make sure
sys.stdin is a tty using isatty().  If some user changes
sys.stdin to point to a tty, but *wants* Python to treat it
as a non-tty, then this might cause them some grief.  I
can't think of any case where they'd want to do that,
though.  The behavior would be unchanged when sys.stdin
points to a regular file.

2) hmm.. I suppose, ideally, the readline module should
smoothly handle sys.stdin being changed out from under it. 
Readline alters various terminal settings on rl_instream
during initialization, though.  For example, it changes the
terminal to raw or cbreak mode from cooked mode, so that it
can receive input a character at a time instead of a line at
a time.  It may be possible to uninitialized and
reinitialized terminal each time call_readline is called, I
suppose (I believe libreadline provides hooks for this).  It
would also have to check if sys.stdin is a tty, and call
PyFile_GetLine if it is not.