Message32560
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'
|
|
Date |
User |
Action |
Args |
2007-08-23 14:58:53 | admin | link | issue1761028 messages |
2007-08-23 14:58:53 | admin | create | |
|