Is there a difference between cPickle / pickle for dump?

G

Guenter Walser

Hello,

When using the codeline:

pickle.dump(self, file, pickle.HIGHEST_PROTOCOL)

my program runs perfectly fine:

--------------------------- Testprotocol
-----------------------------
Initialise an non existing index - creation of persistence files is
tested. ... ok

----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
------------------------- Eo Testprotocol
----------------------------

when using instead:

cPickle.dump(self, file, cPickle.HIGHEST_PROTOCOL)

then it behaves not so well:
--------------------------- Testprotocol
-----------------------------
Initialise an non existing index - creation of persistence files is
tested. ... ERROR

======================================================================
ERROR: Initialise an non existing index - creation of persistence
files is tested.

----------------------------------------------------------------------
Traceback (most recent call last):
File "testIndex.py", line 95, in testInitIndexSuccess
print ind
File "C:\PROGRA~1\Python2.3\lib\site-packages\Kombuka\KBIndex.py",
line 91, in storeIndex
cPickle.dump(self, file, cPickle.HIGHEST_PROTOCOL)
PicklingError: Can't pickle <class 'Kombuka.KBIndex.KBIndex'>:
import of module Kombuka.KBIndex failed

----------------------------------------------------------------------
Ran 1 test in 0.451s
FAILED (errors=1)
------------------------- Eo Testprotocol
----------------------------

Python will start to write into the file, but stops after the first
character.
I can't find any hint in the doc that there is a difference for the dump
method between the two modules.

Self is a dictionary (inherited from dict) with only one entry
(string:string), the environment is Windows XP.

Thanks in advance

Guenter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top