[Xapian-discuss] Python segmentation fault when abstracting value range processor

Richard Boulton richard at lemurconsulting.com
Wed Mar 4 11:33:13 GMT 2009


On Wed, Mar 04, 2009 at 11:05:33AM +0000, James Aylett wrote:
> On Wed, Mar 04, 2009 at 10:56:17AM +0000, Simon Roe wrote:
> > def load_queryparser():
> >   q = xapian.QueryParser()
> >   q.set_default_op(xapian.Query.OP_AND)
> > 
> >   vrp = xapian.NumberValueRangeProcessor(1,'year:')
> >   q.add_valuerangeprocessor(vrp)
> > 
> >   return q
> 
> vrp will be deleted by the python layer. This perhaps isn't what we
> want, but is what is happening right now. You can make this work by
> returning (q, vrp) and assigning the tuple to (qp, vrp) in the rest of
> the code.

This is indeed the problem.  xappy works around a similar problem for
queries by making proxy query objects which wrap any such resources, and
ensure they're not deleted until the (proxy) query object is.  You could
make a proxy QueryParser object for this, similiarly.

-- 
Richard



More information about the Xapian-discuss mailing list