This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author edonmyder
Recipients
Date 2007-07-26.12:36:54
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
unpickle a object with a custom __hash__ fails.

Example (full code is attached):

class Node(object):
    def __init__(self, i):
	self.i = i

    def __cmp__(self, other):
	return cmp(self.i, other.i)

    def __hash__(self):
	return hash(self.i)

n = Node(12)
n.next_nodes = set((n,))

unpickling n give the following error message:
Traceback (most recent call last):
  File "circle.py", line 23, in <module>
    n1 = pickle.load(f1)
  File "/usr/lib/python2.5/pickle.py", line 1370, in load
    return Unpickler(file).load()
  File "/usr/lib/python2.5/pickle.py", line 858, in load
    dispatch[key](self)
  File "/usr/lib/python2.5/pickle.py", line 1133, in load_reduce
    value = func(*args)
  File "circle.py", line 15, in __hash__
    return hash(self.i)
AttributeError: 'Node' object has no attribute 'i'
History
Date User Action Args
2007-08-23 14:58:53adminlinkissue1761028 messages
2007-08-23 14:58:53admincreate