On Tue, 13 Nov 2007, Bill Janssen wrote:

This (in functions.cpp) looks wrong.  You're creating an instance of
ThrowableType, but saying that it's of type JavaError when you call
PyErr_SetObject().

Bill

PyObject *PyErr_SetJavaError(jthrowable throwable)
{
   PyObject *err = t_Throwable::wrapObject(Throwable(throwable));

   PyErr_SetObject(PyExc_JavaError, err);
   Py_DECREF(err);

   return NULL;
}

No, this code gets python to raise an error of type JavaError whose
error argument is the actual java throwable instance, wrapped.

What you see is two layers of wrappers:
  1. Throwable(throwable)
     wraps a C++/JNI wrapper around the actual java throwable
  2. t_Throwable::wrapObject(...)
     wraps the CPython Throwable type around the C++/JNI wrapper so that
     one can make calls on it from python (such as getJavaException())

Once can then call getJavaException() on that JavaError instance to retrieve the java stack trace from the actual java throwable:

  try:
      java(blah)
  except JavaError, e:
      print e.getJavaException().printStackTrace()

Andi..
_______________________________________________
pylucene-dev mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/pylucene-dev

Reply via email to