Title: no syntax error with a multiline command through InteractiveInterpreter
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.5
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: Holloway, fwierzbicki, qny31541, richardwoolliscroft, zyasoft
Priority: Keywords:

Created on 2010-04-08.11:10:55 by richardwoolliscroft, last changed 2014-10-21.19:20:31 by zyasoft.

msg5647 (view) Author: Richard Woolliscroft (richardwoolliscroft) Date: 2010-04-08.11:13:47

I have a Jython interpreter embedded in my Java code. My Java program has part of its GUI which emulates a terminal, so when a user types in a command I send it to the InteractiveInterpreter.runsource method to run the command or throw a syntax error or return true if the command is not complete.

When I try the following multi-line command the InteractiveInterpreter returns true when it should report a Syntax Error and return false:

for in range(1,5): <enter>
    print i <enter>
a = i <enter>

in other words I am calling

myInteractiveInterpreterInstance.runsource("for i in range(5):\n\tprint i\na = i\n\n")

and it returns true
msg7721 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2013-02-20.03:17:38
The two code samples you provided are different - the first is missing an "i" in the for loop, but the second has it. Also I see a tab (\t) in the second one so I'm not sure what you are asking...?
msg8314 (view) Author: Holloway (Holloway) Date: 2014-04-29.12:46:45
This bug is visible running the interpreter from the standalone command line interface as well.

Running jython (eg "java -jar jython-standalone-2.5.3.jar") to get to the prompt, then entering (as above):

for i in range(1,5): <enter>
    print i <enter> #the tab is here as well
a = i <enter>

No error is raised where python would report a syntax error.

validPartialSentence in org.python.core.ParserFacade returns true even when not valid. Error seems to stem from PythonPartialParser.single_input() (should throw an exception but doesn't) which is not included in the source download from
msg9102 (view) Author: Jim Baker (zyasoft) Date: 2014-10-06.03:41:31
Duplicate of #1460, which is fixed
Date User Action Args
2014-10-21 19:20:31zyasoftsetstatus: pending -> closed
2014-10-06 03:41:31zyasoftsetstatus: open -> pending
resolution: duplicate
messages: + msg9102
nosy: + zyasoft
2014-05-02 13:42:53qny31541setnosy: + qny31541
2014-04-29 12:46:47Hollowaysetnosy: + Holloway
messages: + msg8314
2013-02-20 03:17:38fwierzbickisetnosy: + fwierzbicki
messages: + msg7721
versions: + Jython 2.5, - 2.5.1
2010-04-08 11:13:48richardwoolliscroftsetmessages: + msg5647
2010-04-08 11:10:55richardwoolliscroftcreate