Title: NPE when using JSR 223 (TestCase+Patch)
Type: crash Severity: urgent
Components: Core Versions: 2.5.2rc
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fwierzbicki Nosy List: fwierzbicki, kaneiderdaniel
Priority: Keywords: patch

Created on 2011-03-21.17:09:52 by kaneiderdaniel, last changed 2012-03-20.03:29:08 by fwierzbicki.

File name Uploaded Description Edit Remove
pyscriptengine.patch kaneiderdaniel, 2011-03-21.17:09:52 Patch-file
msg6446 (view) Author: dak (kaneiderdaniel) Date: 2011-03-21.17:09:52
The two test cases below exit with a 

	at org.python.core.Py.javas2pys(
	at org.python.jsr223.PyScriptEngine$1.invoke(
	at $Proxy10.toString(Unknown Source)

	public void testGetInterfaceCharSequence1() throws ScriptException, IOException {
		ScriptEngineManager manager = new ScriptEngineManager();
		ScriptEngine engine = manager.getEngineByName("python");
		Invocable invocableEngine = (Invocable) engine;

			"from java.lang import CharSequence\n" +
			"class MyString(CharSequence):\n" +
			"   def length(self): return 3\n" +
			"   def charAt(self, index): return 'a'\n" +
			"   def subSequence(self, start, end): return \"\"\n" +
			"   def toString(self): return \"aaa\"\n" +
			"c = MyString()"));
		CharSequence seq = invocableEngine.getInterface(engine.get("c"), CharSequence.class);
		assertEquals("aaa", seq.toString());

	public void testGetInterfaceCharSequence2() throws ScriptException, IOException {
		ScriptEngineManager manager = new ScriptEngineManager();
		ScriptEngine pythonEngine = manager.getEngineByName("python");
		Invocable invocableEngine = (Invocable) pythonEngine;

			"from java.lang import StringBuilder\r\n" +
			"c = StringBuilder(\"abc\")\r\n"));
		CharSequence seq = invocableEngine.getInterface(pythonEngine.get("c"), CharSequence.class);
		assertEquals("abc", seq.toString());
msg6911 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-03-20.03:29:08
Fixed in -- fix will show up in 2.5.3. Thanks for the patch kaneiderdaniel!
Date User Action Args
2012-03-20 03:29:08fwierzbickisetstatus: open -> closed
resolution: fixed
messages: + msg6911
2012-03-19 23:14:40fwierzbickisetassignee: fwierzbicki
nosy: + fwierzbicki
2011-03-21 17:09:52kaneiderdanielcreate