Message11991

Author jeff.allen
Recipients jeff.allen
Date 2018-05-17.19:50:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1526586641.6.0.682650639539.issue2686@psf.upfronthosting.co.za>
In-reply-to
Content
The logic of Jython's main run() program has become quite tortured, especially regarding the treatment of interactive mode and when to install a line-editing console.

We have a reliable indication (from the launcher) whether out standard input is in fact an interactive console. However, we may not be making full use of it. It woould be good not to depend on isatty here as that depends on reflective access to private data, and as if that were not enough, we are promised it will break in a future version of Java.

When a tty stream is given as an argument ("jython /dev/stdin" or "jython CON"), so that isatty returns true, run() adapts its method of reading to the result of isatty(). However, the behaviour is still not console friendly, since it attempts to read 8192 bytes at once and seems not to recognise line ends.

The logic of CPython's main.c, which has the same purpose as Jython's run(), is also a little complex but is easier to follow. Moreover, it provides the expected behaviour. We should model run() more closely on the reference implementation, diverging only where Java requires it.

Against this, we have made some changes to run() specifically to support ipython, and change risks breaking that. (https://hg.python.org/jython/rev/f08249d267c7) Possibly the requirement is simply to let a client program "type at the prompt" -- there's no .py file to execute, so it is "interactive" in that sense, yet should be line-oriented. It's not clear we do the right thing anymore in these circumstances, which are incidentally also those of #2525.
History
Date User Action Args
2018-05-17 19:50:41jeff.allensetrecipients: + jeff.allen
2018-05-17 19:50:41jeff.allensetmessageid: <1526586641.6.0.682650639539.issue2686@psf.upfronthosting.co.za>
2018-05-17 19:50:41jeff.allenlinkissue2686 messages
2018-05-17 19:50:40jeff.allencreate