Is there a difference between cPickle / pickle for dump?
Guenter Walser
guenter.walser at chello.at
Wed Oct 15 03:38:00 EDT 2003
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
More information about the Python-list
mailing list