[C++-sig] Re: Pickling problem

Pierre Barbier de Reuille pierre.barbier at cirad.fr
Mon Mar 1 17:17:02 CET 2004


I tried to modify my class constructors / destructor like that :

struct BaseWrap : public Base
{
  ...
  BaseWrap( PyObject* self_ ) : self( self_ ) { Py_INCREF( self ); }
  BaseWrap( PyObject* self_, const Base& copy ) : Base( copy ), self(
self_ ) { Py_INCREF( self ); }
  virtual ~BaseWrap()
    {
      Py_DECREF( self );
    }
  ...
}

And now it seems to work. Is there a problem with that ?

Pierre

On Mon, 2004-03-01 at 16:59, Pierre Barbier de Reuille wrote:
> Ok, the problem seems to be with the ownership of the class derived from
> Base. It seems I did not understand well how to transfer the ownership
> from Python to C++.
> 
> The use of auto_ptr does not seems to be enough as soon as I derive the
> class in Python. Is there a way to completly transfer the ownership of
> the object (even the python part of it) to the C++ program ?
-- 
Pierre Barbier de Reuille

INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde
34398 MONTPELLIER CEDEX 5, France

tel   : (33) 4 67 61 65 77    fax   : (33) 4 67 61 56 68 





More information about the Cplusplus-sig mailing list