Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deque pickling problems #41151

Closed
ddorfman mannequin opened this issue Nov 8, 2004 · 5 comments
Closed

deque pickling problems #41151

ddorfman mannequin opened this issue Nov 8, 2004 · 5 comments
Labels
extension-modules C modules in the Modules dir

Comments

@ddorfman
Copy link
Mannequin

ddorfman mannequin commented Nov 8, 2004

BPO 1062279
Nosy @rhettinger
Files
  • deque.diff: Fix and tests
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2004-11-09.07:28:34.000>
    created_at = <Date 2004-11-08.08:10:51.000>
    labels = ['extension-modules']
    title = 'deque pickling problems'
    updated_at = <Date 2004-11-09.07:28:34.000>
    user = 'https://bugs.python.org/ddorfman'

    bugs.python.org fields:

    activity = <Date 2004-11-09.07:28:34.000>
    actor = 'rhettinger'
    assignee = 'none'
    closed = True
    closed_date = None
    closer = None
    components = ['Extension Modules']
    creation = <Date 2004-11-08.08:10:51.000>
    creator = 'ddorfman'
    dependencies = []
    files = ['6358']
    hgrepos = []
    issue_num = 1062279
    keywords = ['patch']
    message_count = 5.0
    messages = ['47270', '47271', '47272', '47273', '47274']
    nosy_count = 2.0
    nosy_names = ['rhettinger', 'ddorfman']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1062279'
    versions = []

    @ddorfman
    Copy link
    Mannequin Author

    ddorfman mannequin commented Nov 8, 2004

    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 bpo-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).

    @ddorfman ddorfman mannequin closed this as completed Nov 8, 2004
    @ddorfman ddorfman mannequin added the extension-modules C modules in the Modules dir label Nov 8, 2004
    @ddorfman ddorfman mannequin closed this as completed Nov 8, 2004
    @ddorfman ddorfman mannequin added the extension-modules C modules in the Modules dir label Nov 8, 2004
    @rhettinger
    Copy link
    Contributor

    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.

    @ddorfman
    Copy link
    Mannequin Author

    ddorfman mannequin commented Nov 8, 2004

    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 bpo-1062277. I think I'll
    post a patch that implements frozenset.__setstate__ tonight,
    but it's less obviously desirable than this one.

    @ddorfman
    Copy link
    Mannequin Author

    ddorfman mannequin commented Nov 8, 2004

    Logged In: YES
    user_id=908995

    set patch filed as SF bpo-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.

    @rhettinger
    Copy link
    Contributor

    Logged In: YES
    user_id=80475

    Accepted and applied with minor modifications. See
    Modules/collectionsmodule.c 1.36

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant