Issue1713

classification
Title: PythonInterpreter.eval doesn't work with multiline string properly
Type: Severity: normal
Components: Jythonc compiler Versions: Jython 2.5
Milestone:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, jan.koprowski
Priority: Keywords:

Created on 2011-02-28.20:22:33 by jan.koprowski, last changed 2013-02-26.17:46:34 by fwierzbicki.

Files
File name Uploaded Description Edit Remove
NiceJython.java jan.koprowski, 2011-02-28.20:22:33
Messages
msg6414 (view) Author: Jan Koprowski (jan.koprowski) Date: 2011-02-28.20:22:33
In attached Java program the goal is evaluate multiline Jython string (containing code) and receive value of this evaluation. For some reason .eval(code) return "None" instead 125. For me it looks like PythonInterpreter evaluate can't handle evaluation of multiline string. This will be nice feature in API - jRuby have ability to evaluate multiline string code with getting result and this i very nice feature.
For now workaround is split lines of code, exec() all except last line of code and pass this last line to eval() - this looks very ugly and complicate code a lot.
msg7792 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2013-02-26.17:46:34
Hi Jan, thanks for the bug report.

In Python/Jython, eval doesn't work like this. For example:

>>> eval("""x = 2
...         x+2""")
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "<string>", line 1
    x = 2
      ^
SyntaxError: invalid syntax

Since you have a workaround, and this really can't be fixed, I'm closing.
History
Date User Action Args
2013-02-26 17:46:34fwierzbickisetstatus: open -> closed
resolution: wont fix
messages: + msg7792
nosy: + fwierzbicki
2013-02-19 23:18:31fwierzbickisetversions: + Jython 2.5, - 25rc4
2011-02-28 20:22:33jan.koprowskicreate