Python bindings should keep a reference to user-subclassable proxies when registered with consumers/users
|Reported by:||James Aylett||Owned by:||Richard Boulton|
Description (last modified by )
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.