Message6446

Author kaneiderdaniel
Recipients kaneiderdaniel
Date 2011-03-21.17:09:52
SpamBayes Score 3.5411026e-06
Marked as misclassified No
Message-id <1300727392.79.0.443216304136.issue1721@psf.upfronthosting.co.za>
In-reply-to
Content
The two test cases below exit with a 

java.lang.NullPointerException
	at org.python.core.Py.javas2pys(Py.java:1559)
	at org.python.jsr223.PyScriptEngine$1.invoke(PyScriptEngine.java:154)
	at $Proxy10.toString(Unknown Source)
        .........

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

		assertNull(engine.eval(
			"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;

		assertNull(pythonEngine.eval(
			"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());
	}
History
Date User Action Args
2011-03-21 17:09:52kaneiderdanielsetrecipients: + kaneiderdaniel
2011-03-21 17:09:52kaneiderdanielsetmessageid: <1300727392.79.0.443216304136.issue1721@psf.upfronthosting.co.za>
2011-03-21 17:09:52kaneiderdaniellinkissue1721 messages
2011-03-21 17:09:52kaneiderdanielcreate