[ python-Bugs-1761028 ] pickle - cannot unpickle circular deps with custom __hash__
SourceForge.net
noreply at sourceforge.net
Thu Jul 26 14:36:54 CEST 2007
Bugs item #1761028, was opened at 2007-07-26 14:36
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1761028&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Martin Süßkraut (edonmyder)
Assigned to: Nobody/Anonymous (nobody)
Summary: pickle - cannot unpickle circular deps with custom __hash__
Initial Comment:
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'
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1761028&group_id=5470
More information about the Python-bugs-list
mailing list