[Patches] [ python-Patches-1062279 ] deque pickling problems

SourceForge.net noreply at sourceforge.net
Mon Nov 8 12:08:25 CET 2004


Patches item #1062279, was opened at 2004-11-08 08:10
Message generated for change (Comment added) made by ddorfman
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1062279&group_id=5470

Category: Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Dima Dorfman (ddorfman)
Assigned to: Nobody/Anonymous (nobody)
Summary: deque pickling problems

Initial Comment:
Two problems with deque.__reduce__:

  1. If one of the elements is self, it ends up in args,
     which makes it impossible for the unpickler to
     correctly supply it. Fixed by using the listitems
     argument (PEP 307 says that non-lists may use this if
     they support append and extend, which deque does)
     (test_pickle_recursive). This is related to SF #1062277
     but does not depend on it.

  2. Since we wrote our reduce, the standard ones don't have
     a chance to save the instance dictionary, so we have to
     do it ourselves (TestSubclass.test_pickle).

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

>Comment By: Dima Dorfman (ddorfman)
Date: 2004-11-08 11:08

Message:
Logged In: YES 
user_id=908995

set patch filed as SF #1062353

I just realized that neither of these patches do anything to
handle __slots__, but I'm not even sure if it's necessary.
At least _reduce_ex tells such classes to write their own
getstate, and such subclasses of set or deque can always
write their own reduce, so lack of such support doesn't make
anything impossible--it just might require a little more
work on the user's part.

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

Comment By: Dima Dorfman (ddorfman)
Date: 2004-11-08 08:51

Message:
Logged In: YES 
user_id=908995

I'm working on set. It definitely has this problem, but an
analogous fix requires introducing frozenset.__setstate__
which would make it possible to mutate a frozenset. A more
correct solution might depend on whether someone finds a
better alternative to my patch in #1062277. I think I'll
post a patch that implements frozenset.__setstate__ tonight,
but it's less obviously desirable than this one.

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

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-11-08 08:44

Message:
Logged In: YES 
user_id=80475

I'll look at this tomorrow.  In the meantime, please check
to see if you have the same problems with set/frozenset.

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1062279&group_id=5470


More information about the Patches mailing list