[PyKDE] deleting the result of sipMapCppToSelf

Jim Bublitz jbublitz at nwinternet.com
Thu Nov 1 18:25:26 GMT 2001


On 01-Nov-01 "DavidGarcia"<david at tss-bcn.com> wrote:
> My code is something like this:
 
> class AKLeft : public AKBase {...};
> ...
> AKLeft        * nope = new AKLeft();
> ...
> obj = sipMapCppToSelf( nope, sipClass_AKBase );
> rslt = PyObject_CallFunction( pcall, "(O)", obj );
> Py_XDECREF( rslt );                   
> Py_XDECREF( obj );
> ...

> Rational Purify doesn't found any leak. Then if I add this code:
 
> obj = sipMapCppToSelf( nope, sipClass_AKLeft );
> rslt = PyObject_CallFunction( pcall, "(O)", obj );
> Py_XDECREF( rslt );                   
> Py_XDECREF( obj );
 
This is just a wild guess, but in "Extending and Embedding the
Python Interpreter" Sect 1.9 (comes with Python), the type formats
are described. The 'O' format increments the reference count of the
object passed - you might try 'N' instead which is the same thing,
but without the increment. Alternatively, try adding a second
Py_XDECREF (obj) each time. It isn't clear to me why that would
cause what you're seeing - it seems you should see the leak without
the second code section too - but it's the only thing I can think
of besides a sip bug.

If that doesn't work, try re-posting the question again in a week
or so when Phil has returned.

Jim





More information about the PyQt mailing list