[C++-sig] Pickling problem

Pierre Barbier de Reuille pierre.barbier at cirad.fr
Mon Mar 1 10:56:48 CET 2004


Hi !

I have a problem with pickling a proxy class. I join the C++ code as an
attached file.

I have three classes :
 - Base : an abstract class
 - Derived : a subclass of Base
 - Proxy : the proxy class that contains an instance of Base

Derived objects can be pickled and the pickling of Proxy just return a
tuple with a Base object in it. Here is a python sample :


>>> import test_abstract
>>> p = test_abstract.Proxy(test_abstract.Derived(10))
>>> import cPickle
>>> cPickle.dumps(p.getBase())
'ctest_abstract\nDerived\np1\n(I10\ntRp2\n.'
>>> cPickle.dumps(p)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
cPickle.PicklingError: Can't pickle <type 'Boost.Python.instance'>:
import of module Boost.Python failed

I really don't know what to do !

Thanks,

Pierre

-- 
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 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_abstract.cc
Type: text/x-c++
Size: 3972 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040301/915ea7d5/attachment.bin>


More information about the Cplusplus-sig mailing list