Issue2712
Created on 2018-10-27.06:15:50 by mete0r, last changed 2018-10-27.14:02:21 by jeff.allen.
Messages | |||
---|---|---|---|
msg12163 (view) | Author: mete0r (mete0r) | Date: 2018-10-27.06:15:48 | |
Example 1: pyinfo.py[1] --------------------- def pyinfo(): import sys <BLANK> return {"version_info": tuple(sys.version_info), "sysplatform": sys.platform} <BLANK> print(pyinfo()) --------------------------------- 1) If you run this file like: jython pyinfo.py it just runs fine, i.e. {'version_info': (2, 7, 1, 'final', 0), 'sysplatform': 'java1.7.0_181 ( ==linux2 for targets )'} 2) But if you feed the file into the interpreter standard input stream, jython < pyinfo.py it spits out syntax error: File "<stdin>", line 1 return {"version_info": tuple(sys.version_info), "sysplatform": sys.platform} ^ SyntaxError: no viable alternative at input ' ' 3) If you remove the first blank line, i.e. def pyinfo(): import sys return {"version_info": tuple(sys.version_info), "sysplatform": sys.platform} <BLANK> print(pyinfo()) you can run the code by giving file name as an argument AND by feeding into standard input. This problem prevents using a Jython interpreter in tox environment. Testing environment ------------------- Debian 8.11 Jessie OpenJDK 1.7.0_181 OpenJDK Runtime Environment (IcedTea 2.6.14) (7u181-2.6.14-1~deb8u1) OpenJDK 64-Bit Server VM (build 24.181-b01, mixed mode) Jython 2.7.1 ------ [1] tox feed this code into python interpreter's standard input |
|||
msg12164 (view) | Author: Jeff Allen (jeff.allen) | Date: 2018-10-27.14:02:20 | |
The Jython main program that handles this has been re-worked in #2686. I noticed that piped input worked badly (maybe not exactly the way you report) and fixed it. So in the development tip, either it works, or I've broken it in entirely new ways. A quick check looks good (Windows cmd): C:\Users\Jeff\Documents\Eclipse\jython-trunk>dist\bin\jython pyinfo.py {'version_info': (2, 7, 2, 'alpha', 1), 'sysplatform': PyShadowString('java1.7.0_80', 'win32')} C:\Users\Jeff\Documents\Eclipse\jython-trunk>dist\bin\jython < pyinfo.py {'version_info': (2, 7, 2, 'alpha', 1), 'sysplatform': PyShadowString('java1.7.0_80', 'win32')} |
History | |||
---|---|---|---|
Date | User | Action | Args |
2018-10-27 14:02:21 | jeff.allen | set | resolution: accepted messages: + msg12164 nosy: + jeff.allen |
2018-10-27 06:15:50 | mete0r | create |
Supported by Python Software Foundation,
Powered by Roundup