Issue1642

classification
Title: JSR223 PyScriptEngine#getInterface returns a NPE when called with zero args
Type: crash Severity: normal
Components: Any Versions: 2.5.2b1
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: juneau001 Nosy List: denis.rangel, juneau001, zyasoft
Priority: high Keywords: patch

Created on 2010-08-15.20:02:34 by denis.rangel, last changed 2010-10-14.12:54:37 by juneau001.

Files
File name Uploaded Description Edit Remove
PyScriptEngine.java denis.rangel, 2010-08-15.20:02:33
jython.diff denis.rangel, 2010-09-23.13:37:40
Messages
msg5974 (view) Author: Denis Guedes Rangel (denis.rangel) Date: 2010-08-15.20:02:33
There is an error when the argument and zero in jsr223 proxy! correction follows below.


Index: src/org/python/jsr223/PyScriptEngine.java
===================================================================
--- src/org/python/jsr223/PyScriptEngine.java	(revisão 7093)
+++ src/org/python/jsr223/PyScriptEngine.java	(cópia de trabalho)
@@ -144,7 +144,13 @@
                         PyObject pyMethod = thiz.__findattr__(method.getName());
                         if (pyMethod == null)
                             throw new NoSuchMethodException(method.getName());
-                        PyObject result = pyMethod.__call__(Py.javas2pys(args));
+
+                        PyObject result;
+                        if(args != null) {
+                            result = pyMethod.__call__(Py.javas2pys(args));
+                        } else {
+                            result = pyMethod.__call__();
+                        }
                         return result.__tojava__(Object.class);
                     } catch (PyException pye) {
                         throw scriptException(pye);
msg5998 (view) Author: Jim Baker (zyasoft) Date: 2010-08-21.04:16:46
This patch looks reasonable to me. Would you mind adding some unit tests, so we can see all the expected cases you expect this to handle?

Probably this would best be done by modifying tests/java/org/python/jsr223/ScriptEngineTest.java

Thanks!
msg6090 (view) Author: Juneau001 (juneau001) Date: 2010-09-22.23:46:58
I will write some unit tests for this.
msg6092 (view) Author: Denis Guedes Rangel (denis.rangel) Date: 2010-09-23.13:37:40
Sorry for the delay. My computer broke, so I can buy one for Christmas ;-(. Here's the complete diff
msg6166 (view) Author: Juneau001 (juneau001) Date: 2010-10-14.12:54:36
Accepted the patch for PyScriptEngine.java.  I had to alter some tests in ScriptEngineTest.java as compared to the .diff that was provided, but everything seems to work fine.  Patch changes have been committed.
History
Date User Action Args
2010-10-14 12:54:37juneau001setstatus: open -> closed
resolution: accepted
messages: + msg6166
2010-09-23 13:37:42denis.rangelsetfiles: + jython.diff
keywords: + patch
messages: + msg6092
2010-09-22 23:46:58juneau001setassignee: juneau001
messages: + msg6090
nosy: + juneau001
2010-09-08 19:34:09zyasoftsetpriority: high
2010-08-21 04:20:19zyasoftsettitle: JSR223 ScriptEngine#getInterface returns a NPE when called with zero args -> JSR223 PyScriptEngine#getInterface returns a NPE when called with zero args
2010-08-21 04:20:11zyasoftsettitle: Proxy jsr223 Nullpointer no arguments -> JSR223 ScriptEngine#getInterface returns a NPE when called with zero args
2010-08-21 04:16:46zyasoftsetnosy: + zyasoft
messages: + msg5998
2010-08-15 20:02:34denis.rangelcreate