lucene-pylucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Janssen <jans...@parc.com>
Subject Re: throwing an exception *through* Java?
Date Mon, 27 Sep 2010 15:22:14 GMT
Andi Vajda <vajda@apache.org> wrote:

> 
> On Mon, 27 Sep 2010, Bill Janssen wrote:
> 
> > Here's a printout of what I'm seeing:
> >
> >  UpLibQueryParser.parse('_query_language:nl janssen')...
> >  => lucene.VERSION: 3.0.2 , jcc._jcc.JCC_VERSION 2.6
> >  => Exception received is JavaError(<Throwable: org.apache.jcc.PythonException:
Query specifies language 'nl'
> >  Traceback (most recent call last):
> >    File "/u/python/uplib/indexing.py", line 591, in getFieldQuery
> >      raise RequiresQueryLanguage(text)
> >  __main__.RequiresQueryLanguage: Query specifies language 'nl'
> >  >,)
> 
> You are using --shared because the exception you're getting is
> PythonException.
> 
> > Is there some way to check to see if lucene is using --shared at runtime?
> 
> No direct way that I can think of at the moment.
> 
> So, it looks like you're getting a JavaError that wraps a PythonException.
> Yet it's wrapped by a JavaError. This could mean that the test that
> checks if the PythonException instance is of class PythonException
> line 426 in JCCEnv.cpp is failing.
> 
> As a hack, try changing that line to do a string compare on the class
> names instead. Or just force it to true, even.

OK, I tried that, no improvement.  I used the 3.0.2 source distro.
Here's my hacked version of reportException:

void JCCEnv::reportException() const
{
    JNIEnv *vm_env = get_vm_env();
    jthrowable throwable = vm_env->ExceptionOccurred();

    if (throwable)
    {
        if (!env->handlers)
            vm_env->ExceptionDescribe();

#ifdef PYTHON
        PythonGIL gil;

        if (PyErr_Occurred())
        {
            /* _thr is PythonException ifdef _jcc_lib (shared mode)
             * if not shared mode, _thr is RuntimeException
             */
            jobject cls = (jobject) vm_env->GetObjectClass(throwable);

            if (true)
            {
#ifndef _jcc_lib
                /* PythonException class is not available without shared mode.
                 * Python exception information thus gets lost and exception
                 * is reported via plain Java RuntimeException.
                 */
                PyErr_Clear();
                throw _EXC_JAVA;
#else
                throw _EXC_PYTHON;
#endif
            }
        }
#endif

        throw _EXC_JAVA;
    }
}

And here's what I see:

Exception received is JavaError(<Throwable: org.apache.jcc.PythonException: Query specifies
language 'nl'
Traceback (most recent call last):
  File "/u/python/uplib/indexing.py", line 591, in getFieldQuery
    raise RequiresQueryLanguage(text)
__main__.RequiresQueryLanguage: Query specifies language 'nl'
>,)

This implies that _jcc_lib (or PYTHON) is not #defined.

Bill

Mime
View raw message