New submission from Kevin Barry <ta0k...@gmail.com>:

I have been trying to get PyRun_InteractiveLoop to run on a pty (Linux) without 
replacing stdin and stdout with that pty; however, it seems like Python (2.6.6) 
is hard-coded to only run interactively on stdin and stdout.


Compile the attached program with:

> gcc `python-config --cflags` working.c -o working `python-config --ldflags`

and run it with:

> ./working xterm -S/0

and you should see that there is no interactivity in the xterm that's opened.


Compile the attached file with:

> gcc -DREADLINE_HACK `python-config --cflags` working.c -o working 
> `python-config --ldflags` -lreadline -lcurses

and run it with:

> ./working xterm -S/0

to see how it runs with my best attempt to get it to function properly with a 
readline hack. Additionally, try running:

> ./working xterm -S/0 > /dev/null
> ./working xterm -S/0 < /dev/null

both of which should cause interactivity in the xterm to fail, indicating that 
Python is checking stdin/stdout for tty status when determining if it should 
run interactively (i.e. it's not checking the tty status of the file passed to 
PyRun_InteractiveLoop.)


Am I somehow using this function wrong? I've been trying to work around this 
problem for a while, and I don't think I should be using readline hacks 
(especially since they don't port to other OSes with ptys, e.g. OS X.) I even 
tried to patch the call to PyOS_Readline in tok_nextc (Parser/tokenizer.c) to 
use tok->fp instead of stdin/stdout, which caused I/O to use the pty but it 
still failed to make interactivity work.


Thanks!

Kevin Barry

----------
components: Interpreter Core, Library (Lib)
files: working.c
messages: 161586
nosy: Kevin.Barry
priority: normal
severity: normal
status: open
title: PyRun_InteractiveLoop fails to run interactively when using a Linux pty 
that's not tied to stdin/stdout
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file25706/working.c

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14916>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to