Bug in cPickle with packages and 'object' inherited class
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Mon Jul 30 00:42:46 EDT 2007
En Wed, 25 Jul 2007 17:32:46 -0300, Conrado PLG <conradoplg at gmail.com>
escribió:
> Say you have this structure:
>
> pna/
> __init__.py
> model.py
>
>
> __init__.py is empty.
>
> model.py is:
>
>
> import cPickle as pickle
>
> class A(object):
> pass
>
> def serialize():
> pickle.dump(A(), open('temp.dat', 'wb'))
>
>
> Now open a python interpreter on the root directory of that structure
> and type:
>
>
> import pna.model
> pna.model.serialize()
>
>
> The following exception is thrown:
>
>
> Traceback (most recent call last):
> File "test.py", line 2, in <module>
> pna.model.serialize()
> File "...\pna\model.py", line 7, in serialize
> pickle.dump(A(), open('temp.dat', 'wb'))
> cPickle.PicklingError: Can't pickle <class 'pna.model.A'>: import of
> module pna.model failed
It works for me. What are those "..." in the file name?
--
Gabriel Genellina
More information about the Python-list
mailing list