Is there a difference between cPickle / pickle for dump?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guenter Walser

    Is there a difference between cPickle / pickle for dump?

    Hello,

    When using the codeline:

    pickle.dump(sel f, 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(se lf, 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 testInitIndexSu ccess
    print ind
    File "C:\PROGRA~1\Py thon2.3\lib\sit e-packages\Kombuk a\KBIndex.py",
    line 91, in storeIndex
    cPickle.dump(se lf, file, cPickle.HIGHEST _PROTOCOL)
    PicklingError: Can't pickle <class 'Kombuka.KBInde x.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


Working...