Bugs item #1581183, was opened at 2006-10-20 12:15 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=1581183&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: None Status: Open Resolution: None Priority: 5 Submitted By: Anders J. Munch (andersjm) Assigned to: Nobody/Anonymous (nobody) Summary: pickle protocol 2 failure on int subclass Initial Comment: I ran into problems pickling a set containing an int subclass which holds a reference to an object which holds a reference to the original object. I reduced it to the attached int_subclass_pickle_problem.py. There are no problems with pickle protocols 0 and 1, but the protocol 2 unit tests fail with an exception. This happens for pickle and cPickle both, although with two different excpeptions. cPickle: TypeError: ('set objects are unhashable', <type 'set'>, ([set([1])],)) pickle: File "....\lib\pickle.py", line 244, in memoize assert id(obj) not in self.memo AssertionError (For the full tracebacks, run the attached script.) I looked into if this was because int implemented __reduce__ or __reduce_ex__, trumping my __getstate__/__setstate__, but that doesn't seem to be the case: >>> int.__reduce_ex__ is object.__reduce_ex__ True >>> int.__reduce__ is object.__reduce__ True After the further simplification of replacing self.orig = [set([E.a]), set([E.a])] with self.orig = E.a cPickle starts working, but pickle still fails. (Seen with Python 2.4.3 and Python 2.5, on W2K.) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1581183&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com