Bugs item #1326448, was opened at 2005-10-14 08:38
Message generated for change (Comment added) made by zseil
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1326448&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: None
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: George Sakkis (gsakkis)
Assigned to: Tim Peters (tim_one)
Summary: set.__getstate__ is not overriden

Initial Comment:
>>> import pickle
>>> class Foo(set):
...     def __getstate__(self): assert False

>>> pickle.dumps(Foo())
# doesn't raise AssertionError

The same happens with frozenset.

----------------------------------------------------------------------

Comment By: Žiga Seilnacht (zseil)
Date: 2006-04-01 03:37

Message:
Logged In: YES 
user_id=1326842

The problem is that __reduce__() and __reduce_ex__()
have complete control over the process of pickling.

The simple solution would be to switch to the
__getnewargs__() method for pickle protocol 2
(this is simple, __getnewargs__() should
return a tuple which is passed to the constructor
when unpickling. This means that you can reuse the
part of the current code that creates the args tuple)

For protocols 0 and 1, the following should be added
to the copy_reg module:

def pickle_set(s):
    return set, list(s)

pickle(set, pickle_set, set)

def pickle_frozenset(s):
    return frozenset, list(s)

pickle(set, pickle_set, set)


The other options are:
 - copy the semantics from object_reduce_ex
 - add support directly to pickle and cPickle

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2005-10-14 16:37

Message:
Logged In: YES 
user_id=80475

Tim, do you have any thoughts on this?  I'm unclear on
whether this is a bug in set(), in copy_reg, in pickle, or
even a bug at all.

setobject.c implements pickling via a __reduce__() method. 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1326448&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to