Hi Neil,
as you know there are two Python engines available, "jython" and
"jpython" (not that it makes a difference for your problem, but it might
be interesting to know).
Your test program runs nicely standalone, when invoked via the command
line using BSF it bombs as you reported. It seems that the error comes
from jython.
Here's the content of a file named "test.py" containing almost what you
wrote:
------------ cut here ----------
def test ():
return 1
print test()
------------ cut here ----------
It runs flawlessly with Python.
Here are the results of running it via BSF under different versions of Java
from the command line (using org.apache.bsf.Main):
using the "jython" engine with Java 3:
------------ cut here ----------
E:\rony\dev\bsf\src\samples\bsf_samples\bsh>java org.apache.bsf.Main -in
test.py -lang jython
[ERROR] BSFManager - Exception: <java.security.PrivilegedActionException
<<org.apache.bsf.BSFException: exception from Jython:
Traceback (innermost last):
(no code object) at line 0
SyntaxError: ('invalid syntax', ('<string>', 1, 1, 'def test ():'))
java.security.PrivilegedActionException: org.apache.bsf.BSFException: exception
from Jython:
Traceback (innermost last):
(no code object) at line 0
SyntaxError: ('invalid syntax', ('<string>', 1, 1, 'def test ():'))
at org.apache.bsf.engines.jython.JythonEngine.eval(JythonEngine.java:168)
at org.apache.bsf.BSFManager$5.run(BSFManager.java:470)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.bsf.BSFManager.eval(BSFManager.java:467)
at org.apache.bsf.Main.main(Main.java:154)
exception from Jython:
Traceback (innermost last):
(no code object) at line 0
SyntaxError: ('invalid syntax', ('<string>', 1, 1, 'def test ():'))
: Traceback (innermost last):
(no code object) at line 0
File "<string>", line 1
def test ():
^
SyntaxError: invalid syntax
------------ cut here ----------
using the "jpython" engine with Java 3:
------------ cut here ----------
E:\rony\dev\bsf\src\samples\bsf_samples\bsh>java org.apache.bsf.Main -in
test.py -lang jpython
Traceback (innermost last):
(no code object) at line 0
File "<string>", line 1
def test ():
^
SyntaxError: invalid syntax
[ERROR] BSFManager - Exception: <java.security.PrivilegedActionException
<<org.apache.bsf.BSFException: exception from JPython: Traceback (innermost last):
(no code object) at line 0
File "<string>", line 1
def test ():
^
SyntaxError: invalid syntax
java.security.PrivilegedActionException: org.apache.bsf.BSFException: exception
from JPython: Traceback (innermost last):
(no code object) at line 0
File "<string>", line 1
def test ():
^
SyntaxError: invalid syntax
at
org.apache.bsf.engines.jpython.JPythonEngine.eval(JPythonEngine.java:120)
at org.apache.bsf.BSFManager$5.run(BSFManager.java:470)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.bsf.BSFManager.eval(BSFManager.java:467)
at org.apache.bsf.Main.main(Main.java:154)
exception from JPython: Traceback (innermost last):
(no code object) at line 0
File "<string>", line 1
def test ():
^
SyntaxError: invalid syntax
: Traceback (innermost last):
(no code object) at line 0
File "<string>", line 1
def test ():
^
SyntaxError: invalid syntax
------------ cut here ----------
using the "jython" engine with Java 4:
------------ cut here ----------
E:\temp\bsf>java org.apache.bsf.Main -in test.py -lang jython
exception from Jython:
Traceback (innermost last):
(no code object) at line 0
SyntaxError: ('invalid syntax', ('<string>', 1, 1, 'def test():'))
: Traceback (innermost last):
(no code object) at line 0
File "<string>", line 1
def test():
^
SyntaxError: invalid syntax
------------ cut here ----------
using the "jpython" engine with Java 4:
------------ cut here ----------
E:\temp\bsf>java org.apache.bsf.Main -in test.py -lang jpython
Traceback (innermost last):
(no code object) at line 0
File "<string>", line 1
def test():
^
SyntaxError: invalid syntax
exception from JPython: Traceback (innermost last):
(no code object) at line 0
File "<string>", line 1
def test():
^
SyntaxError: invalid syntax
: Traceback (innermost last):
(no code object) at line 0
File "<string>", line 1
def test():
^
SyntaxError: invalid syntax
------------ cut here ----------
using the "jython" engine with Java 5:
------------ cut here ----------
E:\rony\dev\bsf\src\samples\bsf_samples\bsh>java org.apache.bsf.Main -in
test.py -lang jython
Jun 6, 2006 10:27:32 PM org.apache.bsf.BSFManager eval
SEVERE: Exception:
java.security.PrivilegedActionException: org.apache.bsf.BSFException: exception
from Jython:
Traceback (innermost last):
(no code object) at line 0
SyntaxError: ('invalid syntax', ('<string>', 1, 1, 'def test ():'))
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.bsf.BSFManager.eval(BSFManager.java:467)
at org.apache.bsf.Main.main(Main.java:154)
Caused by: org.apache.bsf.BSFException: exception from Jython:
Traceback (innermost last):
(no code object) at line 0
SyntaxError: ('invalid syntax', ('<string>', 1, 1, 'def test ():'))
at org.apache.bsf.engines.jython.JythonEngine.eval(JythonEngine.java:168)
at org.apache.bsf.BSFManager$5.run(BSFManager.java:470)
... 3 more
exception from Jython:
Traceback (innermost last):
(no code object) at line 0
SyntaxError: ('invalid syntax', ('<string>', 1, 1, 'def test ():'))
: Traceback (innermost last):
(no code object) at line 0
File "<string>", line 1
def test ():
^
SyntaxError: invalid syntax
------------ cut here ----------
using the "jpython" engine with Java 5:
------------ cut here ----------
E:\rony\dev\bsf\src\samples\bsf_samples\bsh>java org.apache.bsf.Main -in
test.py -lang jpython
Traceback (innermost last):
(no code object) at line 0
File "<string>", line 1
def test ():
^
SyntaxError: invalid syntax
Jun 6, 2006 10:29:23 PM org.apache.bsf.BSFManager eval
SEVERE: Exception:
java.security.PrivilegedActionException: org.apache.bsf.BSFException: exception
from JPython: Traceback (innermost last):
(no code object) at line 0
File "<string>", line 1
def test ():
^
SyntaxError: invalid syntax
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.bsf.BSFManager.eval(BSFManager.java:467)
at org.apache.bsf.Main.main(Main.java:154)
Caused by: org.apache.bsf.BSFException: exception from JPython: Traceback
(innermost last):
(no code object) at line 0
File "<string>", line 1
def test ():
^
SyntaxError: invalid syntax
at
org.apache.bsf.engines.jpython.JPythonEngine.eval(JPythonEngine.java:120)
at org.apache.bsf.BSFManager$5.run(BSFManager.java:470)
... 3 more
exception from JPython: Traceback (innermost last):
(no code object) at line 0
File "<string>", line 1
def test ():
^
SyntaxError: invalid syntax
: Traceback (innermost last):
(no code object) at line 0
File "<string>", line 1
def test ():
^
SyntaxError: invalid syntax
------------ cut here ----------
Not sure where the error comes from...
---rony
P.S.: Also tried it with Jython 2.2alpha on Java 4 with the same results...
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]