Issue2325
Created on 2015-04-13.19:24:58 by jmadden, last changed 2015-04-15.20:34:48 by zyasoft.
File name |
Uploaded |
Description |
Edit |
Remove |
2325.patch
|
jmadden,
2015-04-14.14:41:54
|
Interactive prompt patch v1 |
|
|
msg9812 (view) |
Author: Jason Madden (jmadden) |
Date: 2015-04-13.19:24:58 |
|
In Jython 2.7rc2, if the stdin is a pipe, the printing of the interactive prompts is not suppressed. This worked in 2.5:
$ echo 'print 1' | python2.7
1
$ echo 'print 1' | pypy
1
$ echo 'print 1' | jython2.5.4/bin/jython
1
$ echo 'print 1' | jython2.7rc2/bin/jython
>>> 1
>>>
$
(Both versions print an extra newline, but that's probably ok.)
Unfortunately, this breaks `tox`:
$ tox --version
1.9.2 imported from ...
$ tox -e jython
GLOB sdist-make: transaction/setup.py
jython create: transaction/.tox/jython
ERROR: InvocationError: Failed to get version_info for jython: could not decode ">>> ... ... ... >>> {'version_info': (2, 7, 0, 'candidate', 2)}\n>>> "
|
msg9816 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-04-13.21:49:24 |
|
The launcher, being written in CPython, can truly figure out if interactive or not, which we can see like so:
$ echo 'print 1' | ~/jython2.7rc2/bin/jython --print
java -Xmx512m -Xss1024k -classpath /Users/jbaker/jython2.7rc2/jython.jar -Dpython.home=/Users/jbaker/jython2.7rc2 -Dpython.executable=/Users/jbaker/jython2.7rc2/bin/jython -Dpython.launcher.uname=darwin -Dpython.launcher.tty=false -Dfile.encoding=UTF-8 org.python.util.jython
So -Dpython.launcher.tty=false should be authoritative, but it does not appear to be the case.
|
msg9836 (view) |
Author: Jason Madden (jmadden) |
Date: 2015-04-14.14:41:54 |
|
The attached patch seems to do it for me. There were two issues; the first is that InteractiveConsole.interact() always resets the prompts, even if it they had previously been set to empty, so we need to call `_interact` if we're not interactive instead. Second, like you said 'python.launcher.tty' wasn't always being respected as authoritative.
$ dist/bin/jython
Jython 2.7rc2+ (default:5064a5c5b1a3+, Apr 14 2015, 09:32:56)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_40
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
$ dist/bin/jython.py
Jython 2.7rc2+ (default:5064a5c5b1a3+, Apr 14 2015, 09:32:56)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_40
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
$ echo 'print 1' | dist/bin/jython.py
1
$ echo 'print 1' | dist/bin/jython
1
$
(This is my first time trying to suggest a patch here, and I haven't spent any time trying to look back at previous bug reports to see how patches are usually attached so I probably did it wrong. I just wanted to get this up there quickly. I'll take a look to see if I can find better conventions.)
|
msg9838 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-04-14.15:26:59 |
|
Patch looks good, I will add a test based on your initial bug report, and we should be good.
|
msg9841 (view) |
Author: Jason Madden (jmadden) |
Date: 2015-04-14.15:33:47 |
|
Thank you! I'm just learning my way around the codebase so I wasn't sure where a test case would go. I will look forward to seeing it in the commit.
|
msg9863 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-04-15.19:03:49 |
|
Fixed as of https://hg.python.org/jython/rev/cc3e787c0a7c
|
msg9864 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-04-15.19:04:21 |
|
I also removed the extra \n (or \r\n on Windows)
|
msg9865 (view) |
Author: Jason Madden (jmadden) |
Date: 2015-04-15.19:10:34 |
|
Good idea, makes sense, sorry I missed that. With that change, I see no difference in the 'echo' examples anymore, which is a big part of the Tox battle :) Thank you!
|
|
Date |
User |
Action |
Args |
2015-04-15 20:34:48 | zyasoft | set | status: pending -> closed |
2015-04-15 19:10:34 | jmadden | set | messages:
+ msg9865 |
2015-04-15 19:04:21 | zyasoft | set | messages:
+ msg9864 |
2015-04-15 19:03:49 | zyasoft | set | status: open -> pending resolution: accepted -> fixed messages:
+ msg9863 |
2015-04-15 01:57:33 | zyasoft | set | milestone: Jython 2.7.0 |
2015-04-14 15:33:48 | jmadden | set | messages:
+ msg9841 |
2015-04-14 15:26:59 | zyasoft | set | messages:
+ msg9838 |
2015-04-14 14:41:54 | jmadden | set | files:
+ 2325.patch keywords:
+ patch messages:
+ msg9836 |
2015-04-13 21:49:24 | zyasoft | set | priority: urgent assignee: zyasoft resolution: accepted messages:
+ msg9816 nosy:
+ zyasoft |
2015-04-13 19:24:58 | jmadden | create | |
|