> I changed your sample code to raise a JavaError with a Java RuntimeException 
> as argument in getBooleanQuery() and stepping through throwPythonError() 
> shows that the code there is correct. 'value' is the JavaError exception 
> instance and calling 'getJavaException()' on it returns the 
> RuntimeException.
> 
> If there is a bug, it's elsewhere.
> 
> Andi..

Interesting.  Here's the version of throwPythonError that I'm running.

Bill
--------------------------

void throwPythonError(void)
{
    PyObject *exc = PyErr_Occurred();

    if (exc && PyErr_GivenExceptionMatches(exc, PyExc_JavaError))
    {
        PyObject *value, *traceback;

        PyErr_Fetch(&exc, &value, &traceback);
        Py_XDECREF(traceback);

        if (value and PyObject_TypeCheck(value, &ThrowableType)) {
            Py_DECREF(exc);
            exc = value;
        } else if (value and PyObject_TypeCheck(value, PyExc_JavaError)) {
            Py_DECREF(exc);
            exc = PyObject_CallMethod(value, "getJavaException", "");
            Py_DECREF(value);
        }

        if (exc && PyObject_TypeCheck(exc, &ThrowableType))
            {
                jobject jobj = ((t_Throwable *) exc)->object.this$;

                env->get_vm_env()->Throw((jthrowable) jobj);
                Py_DECREF(exc);

            }
        return;
    }

    if (exc && PyErr_GivenExceptionMatches(exc, PyExc_StopIteration))
    {
        PyErr_Clear();
        return;
    }

    env->get_vm_env()->ThrowNew(RuntimeException::initializeClass(),
                                "PythonError");
}

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

Reply via email to