AssertionError in pickle's memoize function

Tim Peters tim.peters at gmail.com
Fri Oct 29 14:30:47 EDT 2004


[Michael Hohn]
> under python 2.2, the pickle/unpickle sequence incorrectly restores
> a larger data structure I have.
>
> Under Python 2.3, these structures now give an explicit exception from
> Pickle.memoize():
>    assert id(obj) not in self.memo
> 
> I'm shrinking the offending data structure down to find the problem
> and provide an easily reproducible example,
> but maybe someone on the list could tell me under what general
> conditions this assertion is expected to fail.

Assertions are never expected to fail, so "something impossible
happened" when they do fail.

See whether your Python has Lib/pickletools.py.  There's an enormous
amount of info about pickles in that (for example, it will tell you
what "memo" means).

May help to try cPickle instead of pickle.  Since they're distinct
implementations, they have different bugs.  cPickle can be much faster
than pickle, but it's a lot easier to understand pickle.py.



More information about the Python-list mailing list