>>> import traceback
>>> from java.lang import *
>>> try:
... String( None )
... except Exception, x:
... print "As Python:"
... traceback.print_exc()
... print "As Java:"
... x.printStackTrace()
...
As Python:
Traceback (most recent call last):
File "<console>", line 2, in ?
java.lang.NullPointerException: java.lang.NullPointerException
As Java:
java.lang.NullPointerException
at java.lang.String.<init>(String.java:193)
at java.lang.reflect.Constructor.newInstance(Native Method)
at org.python.core.PyReflectedConstructor.__call__(PyReflectedConstructor.java)
at org.python.core.PyJavaInstance.__init__(PyJavaInstance.java)
at org.python.core.PyJavaClass.__call__(PyJavaClass.java)
at org.python.core.PyObject.__call__(PyObject.java)
at org.python.pycode._pyx9.f$0(<console>:2)
at org.python.pycode._pyx9.call_function(<console>)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyCode.call(PyCode.java)
at org.python.core.Py.runCode(Py.java)
at org.python.core.Py.exec(Py.java)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java)
at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java)
at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java)
at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java)
at org.python.util.InteractiveConsole.push(InteractiveConsole.java)
at org.python.util.InteractiveConsole.interact(InteractiveConsole.java)
at org.python.util.jython.main(jython.java)
>>>
kb
Yang Wang wrote:
>
> Hi All,
>
> I have read the book "Learning Python" and almost all online docs but
> could not find info on how to print out the entire stack trace of Java
> Exceptions. Any ideas?
>
> Thanks in advance.
>
> Yang
>
> _______________________________________________
> Jython-users mailing list
> Jyt...@li...
> https://lists.sourceforge.net/lists/listinfo/jython-users
|