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 Kevin.Barry
Recipients Kevin.Barry
Date 2012-05-25.15:42:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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.


Kevin Barry
Date User Action Args
2012-05-25 15:42:38Kevin.Barrysetrecipients: + Kevin.Barry
2012-05-25 15:42:38Kevin.Barrysetmessageid: <>
2012-05-25 15:42:37Kevin.Barrylinkissue14916 messages
2012-05-25 15:42:37Kevin.Barrycreate