Issue1490
Created on 2009-10-20.16:49:30 by rmacaulay, last changed 2009-12-09.07:49:09 by nriley.
msg5248 (view) |
Author: Robert Macaulay (rmacaulay) |
Date: 2009-10-20.16:49:29 |
|
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()
|
msg5314 (view) |
Author: Nicholas Riley (nriley) |
Date: 2009-11-18.05:04:42 |
|
Wow, this was dumb. Will fix.
|
msg5364 (view) |
Author: Nicholas Riley (nriley) |
Date: 2009-12-09.07:49:08 |
|
Fixed. Sorry for the delay.
|
|
Date |
User |
Action |
Args |
2009-12-09 07:49:09 | nriley | set | status: open -> closed resolution: fixed messages:
+ msg5364 |
2009-11-18 05:04:42 | nriley | set | assignee: nriley messages:
+ msg5314 nosy:
+ nriley |
2009-10-20 16:49:30 | rmacaulay | create | |
|