Skip to content

Assigning a dict to the memo of an Unpickler object fails #111066

Description

@PCigales

Bug report

Bug description:

Hi,

When using the C accelerated implementation of the pickle module, assigning a dict to the memo of an Unpickler object leads to clearing the memo.
I think there is an error in Unpickler_set_memo as instructions at lines 7493 to 7495 (MemoCleanup and assignment of new_memo to self->memo) cancels the result of instruction at line 7482 (MemoPut).

Thanks in advance.

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Linked PRs

Activity

  1. PCigales commented on Oct 19, 2023

    @PCigales
    Author

    Assigning a memo from an already used Unpickler object to a brand new one leads to an error ("memo value not found") when trying to use it to unpickle the same byte sequence. I suspect it is because memo_len of target is not set to memo_len from source, either by using _Unpickler_MemoPut after switching to the new blank memo rather than copying or by doing the assignment at the end of Unpickler_set_memo.

  2. added a commit that references this issue on Nov 11, 2026
  3. added a commit that references this issue on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions