[Xapian-tickets] [Xapian] #341: Python bindings should keep a reference to user-subclassable proxies when registered with consumers/users

Xapian nobody at xapian.org
Wed Mar 4 12:08:03 GMT 2009


#341: Python bindings should keep a reference to user-subclassable proxies when
registered with consumers/users
-----------------------------+----------------------------------------------
 Reporter:  james            |       Owner:  olly     
     Type:  defect           |      Status:  new      
 Priority:  normal           |   Milestone:           
Component:  Xapian-bindings  |     Version:  SVN trunk
 Severity:  normal           |   Blockedby:           
 Platform:  All              |    Blocking:           
-----------------------------+----------------------------------------------
 Due to #186 and the way the bindings work, if (for instance) you create a
 ValueRangeProcessor proxy object and register it with the QueryParser
 proxy object, then throw away your reference to the ValueRangeProcessor
 proxy, python is left with no references to it, and so will garbage
 collect it. This then causes a segfault when the underlying Xapian
 QueryParser object tries to go ahead and use the ValueRangeProcessor
 object.

 A proposed interim solution until this can be solved more cleanly is to
 stash a reference to the VRP proxy on the QueryParser proxy. Something
 like:

 {{{
 real_add_valuerangeprocessor = QueryParser.add_valuerangeprocessor
 def intercept_add_valuerangeprocessor(self, vrproc):
     self._vrps.append(vrproc)
     real_add_valuerangeprocessor(self, vrproc)
 QueryParser._vrps = []
 QueryParser.add_valuerangeprocessor = intercept_add_valuerangeprocessor
 }}}

 in python/extra.i should do it. Note that this is only one situation where
 we want to be able to make things easier for python users; this should be
 considered in every situation where something is user-subclassable, and
 then documented very clearly.

-- 
Ticket URL: <http://trac.xapian.org/ticket/341>
Xapian <http://xapian.org/>
Xapian



More information about the Xapian-tickets mailing list