Message6132

Author spider
Recipients spider
Date 2010-10-04.08:32:43
SpamBayes Score 5.6626925e-13
Marked as misclassified No
Message-id <1286181166.34.0.630232697109.issue1663@psf.upfronthosting.co.za>
In-reply-to
Content
Our code uses a displayhook (see www.python.org/dev/peps/pep-0217/). It works in Jython 2.5.1, but fails in 2.5.1rc1 and 2.5.2rc2 with the following traceback:

2010-10-01 10:36:26,318 WARN  [gda.jython.GDAInteractiveConsole] - InteractiveConsole exception: Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: displayhook(): expected 1 args; got 0

org.python.core.PyException
	at org.python.core.PyException.fillInStackTrace(PyException.java:70) [jython.jar:na]
	at java.lang.Throwable.<init>(Throwable.java:181) [na:1.6.0_16]
	at java.lang.Exception.<init>(Exception.java:29) [na:1.6.0_16]
	at java.lang.RuntimeException.<init>(RuntimeException.java:32) [na:1.6.0_16]
	at org.python.core.PyException.<init>(PyException.java:46) [jython.jar:na]
	at org.python.core.PyException.<init>(PyException.java:43) [jython.jar:na]
	at org.python.core.PyException.<init>(PyException.java:61) [jython.jar:na]
	at org.python.core.Py.TypeError(Py.java:221) [jython.jar:na]
	at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:209) [jython.jar:na]
	at org.python.core.PyReflectedFunction.throwArgCountError(PyReflectedFunction.java:262) [jython.jar:na]
	at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:319) [jython.jar:na]
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:167) [jython.jar:na]
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204) [jython.jar:na]
	at org.python.core.PyObject.__call__(PyObject.java:387) [jython.jar:na]
	at org.python.core.PyObject.invoke(PyObject.java:3585) [jython.jar:na]
	at org.python.core.Py.printResult(Py.java:1792) [jython.jar:na]
	at org.python.pycode._pyx69.f$0(<input>:1) [na:na]
	at org.python.pycode._pyx69.call_function(<input>) [na:na]
	at org.python.core.PyTableCode.call(PyTableCode.java:165) [jython.jar:na]
	at org.python.core.PyCode.call(PyCode.java:18) [jython.jar:na]
	at org.python.core.Py.runCode(Py.java:1253) [jython.jar:na]
	at org.python.core.Py.exec(Py.java:1297) [jython.jar:na]
	at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:215) [jython.jar:na]
	at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:89) [jython.jar:na]
	at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:70) [jython.jar:na]
	at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:42) [jython.jar:na]
	at gda.jython.GDAJythonInterpreter.populateNamespace(GDAJythonInterpreter.java:493) [main/:na]
	at gda.jython.GDAJythonInterpreter.initialise(GDAJythonInterpreter.java:463) [main/:na]
	at gda.jython.JythonServer.configure(JythonServer.java:338) [main/:na]
	at gda.factory.FactoryBase.configure(FactoryBase.java:64) [main/:na]
	at gda.util.ObjectCreatorsObjectServer.startServer(ObjectCreatorsObjectServer.java:288) [main/:na]
	at gda.util.ObjectServer.configure(ObjectServer.java:335) [main/:na]
	at gda.util.ObjectServer.createServerImpl(ObjectServer.java:133) [main/:na]
	at gda.util.ObjectServer.main(ObjectServer.java:503) [main/:na]
2010-10-01 10:36:26,424 WARN  [gda.jython.GDAInteractiveConsole] - InteractiveConsole exception: Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: displayhook(): expected 1 args; got 0


displayhook itself is fairly simple:
    public static void displayhook(PyObject o) {
        /* Print value except if None */
        /* After printing, also assign to '_' */
        /* Before, set '_' to None to avoid recursion */
        if (o == Py.None)
             return;

        PyObject currentBuiltins = Py.getSystemState().getBuiltins();
        currentBuiltins.__setitem__("_", Py.None);
        if (o instanceof PyUnicode) {
        	PyUnicode u = (PyUnicode)o;
			Py.println(u.__str__());
		} else {
			Py.println(o.__repr__());
		}
        currentBuiltins.__setitem__("_", o);
    }


Unfortunately this is part of a fairly large code base, and at this point I haven't pulled out a simple test case for you.

A quick glance at the change log doesn't throw up any obvious candidates.
History
Date User Action Args
2010-10-04 08:32:46spidersetrecipients: + spider
2010-10-04 08:32:46spidersetmessageid: <1286181166.34.0.630232697109.issue1663@psf.upfronthosting.co.za>
2010-10-04 08:32:46spiderlinkissue1663 messages
2010-10-04 08:32:43spidercreate