Index: src/org/python/core/PySystemState.java =================================================================== --- src/org/python/core/PySystemState.java (revision 6797) +++ src/org/python/core/PySystemState.java (working copy) @@ -1224,6 +1224,10 @@ tb == null ? Py.None : tb); } + public String java_trace(PyObject value) { + return Py.getJavaExceptionTrace(value); + } + public static void exc_clear() { Py.getThreadState().exception = null; } Index: src/org/python/core/Py.java =================================================================== --- src/org/python/core/Py.java (revision 6797) +++ src/org/python/core/Py.java (working copy) @@ -995,6 +995,20 @@ ts.exception = null; } + /* Bug 1435: Adding a method to expose java stack trace. This code is + * copied from displayException() below. + */ + public static String getJavaExceptionTrace(PyObject value) { + if (value.getJavaProxy() != null) { + Object javaError = value.__tojava__(Throwable.class); + + if (javaError != null && javaError != Py.NoConversion) { + return getStackTrace((Throwable) javaError); + } + } + return null; + } + public static void displayException(PyObject type, PyObject value, PyObject tb, PyObject file) { StdoutWrapper stderr = Py.stderr; --- CPythonLib/traceback.py 2009-07-29 11:40:00.000000000 -0400 +++ dist/Lib/traceback.py 2009-09-14 14:00:52.000000000 -0400 @@ -206,7 +206,11 @@ if value is None or not valuestr: line = "%s\n" % etype else: - line = "%s: %s\n" % (etype, valuestr) + java_trace = sys.java_trace(value) + if java_trace is not None: + line = "%s\n%s: %s\n" % (java_trace, etype, valuestr) + else: + line = "%s: %s\n" % (etype, valuestr) return line def _some_str(value):