Dict in binary pickle causes exception

Tim Peters tim.one at comcast.net
Sun Jul 21 01:50:34 EDT 2002


[greg, on MacPython 2.2]
> When I try to unpickle a pickle containing a dictionary
> that was written in binary format, I get the following
> exception:
>
>    TypeError: dict objects are unhashable
>
> The same thing happens whether I use pickle or cPickle
> to do the unpickling.

It's much more useful to show code than to try to describe.  Here:

Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cPickle
>>> d = {1: 2}
>>> s = cPickle.dumps(d, 1)
>>> cPickle.loads(s)
{1: 2}
>>>

>>> import pickle
>>> s = pickle.dumps(d)
>>> pickle.loads(s)
{1: 2}
>>>

No problems for me.  Show us what you do that fails.





More information about the Python-list mailing list