Message5248
In org.python.jsr223.PyScriptEngine.invokeFunction(...), the catch
block calls throwInvokeException.
The idea being if you call a top level method that doesn't exist, it
will throw a NoSuchMethodException. However, if the python function
you call(that exists) throws a PyException like this,
Traceback (most recent call last):
File "<script>", line 19, in inform
AttributeError: 'java.util.HashMap' object has no attribute 'iteritems'
The catch will call throwInvokeException() which will throw a
NoSuchMethod exception with the top level method name as the problem
since the pyException is an AttributeError. In this case, I have just
called an invalid method inside the python script, but it gets masked as
a top level miss.
It seems the invokeFunction already can throw the NoSuchMethod
exception. So the catch block can be changed like this.
--- PyScriptEngine.java.orig 2009-10-15 10:50:28.000000000 -0500
+++ PyScriptEngine.java 2009-10-15 10:51:13.000000000 -0500
@@ -111,7 +111,7 @@
}
return
function.__call__(Py.javas2pys(args)).__tojava__(Object.class);
} catch (PyException pye) {
- return throwInvokeException(pye, name);
+ throw scriptException(pye);
}
}
It looks like the invokeMethod method could suffer from the same
problem, but I'm not sure if the same fix would apply there.
A possible alternative that would cover both cases would be to append
the pye.toString() result inside the NoSuchMethodException constructor
in throwInvokeException() |
|
Date |
User |
Action |
Args |
2009-10-20 16:49:31 | rmacaulay | set | recipients:
+ rmacaulay |
2009-10-20 16:49:30 | rmacaulay | set | messageid: <1256057370.93.0.378883431987.issue1490@psf.upfronthosting.co.za> |
2009-10-20 16:49:30 | rmacaulay | link | issue1490 messages |
2009-10-20 16:49:29 | rmacaulay | create | |
|