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

pickle.py bytearray memoization bug with protocol 5 #88073

Closed
cfbolz mannequin opened this issue Apr 21, 2021 · 3 comments
Closed

pickle.py bytearray memoization bug with protocol 5 #88073

cfbolz mannequin opened this issue Apr 21, 2021 · 3 comments
Labels
3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@cfbolz
Copy link
Mannequin

cfbolz mannequin commented Apr 21, 2021

BPO 43907
Nosy @pitrou, @cfbolz
PRs
  • bpo-43907: add missing memoize call in pure python pickling of bytearray #25501
  • 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 2021-04-23.21:28:19.068>
    created_at = <Date 2021-04-21.18:08:15.207>
    labels = ['type-bug', 'library', '3.10']
    title = 'pickle.py bytearray memoization bug with protocol 5'
    updated_at = <Date 2021-04-23.21:28:19.066>
    user = 'https://github.com/cfbolz'

    bugs.python.org fields:

    activity = <Date 2021-04-23.21:28:19.066>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-04-23.21:28:19.068>
    closer = 'pitrou'
    components = ['Library (Lib)']
    creation = <Date 2021-04-21.18:08:15.207>
    creator = 'Carl.Friedrich.Bolz'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43907
    keywords = ['patch']
    message_count = 3.0
    messages = ['391537', '391737', '391738']
    nosy_count = 2.0
    nosy_names = ['pitrou', 'Carl.Friedrich.Bolz']
    pr_nums = ['25501']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue43907'
    versions = ['Python 3.10']

    @cfbolz
    Copy link
    Mannequin Author

    cfbolz mannequin commented Apr 21, 2021

    The new codepath for the BYTEARRAY8 bytecode is missing memoization:

    >>> import pickletools, pickle
    >>> b = (bytearray(b"abc"), ) * 2
    >>> b1, b2 = pickle.loads(pickle.dumps(b, 5)) # C version
    >>> b1 is b2
    True
    (bytearray(b'abc'), bytearray(b'abc'))
    >>> b1, b2 = pickle.loads(pickle._dumps(b, 5)) # python version
    >>> b1 is b2 # :-(
    False

    Found it because PyPy is using pickle.py with no C implementation. I'm preparing a patch.

    @pitrou
    Copy link
    Member

    pitrou commented Apr 23, 2021

    New changeset 1e9f093 by Carl Friedrich Bolz-Tereick in branch 'master':
    bpo-43907: add missing memoize call in pure python pickling of bytearray (GH-25501)
    1e9f093

    @pitrou
    Copy link
    Member

    pitrou commented Apr 23, 2021

    Thanks for the report and fix!

    @pitrou pitrou added 3.10 only security fixes stdlib Python modules in the Lib dir labels Apr 23, 2021
    @pitrou pitrou closed this as completed Apr 23, 2021
    @pitrou pitrou added type-bug An unexpected behavior, bug, or error 3.10 only security fixes stdlib Python modules in the Lib dir labels Apr 23, 2021
    @pitrou pitrou closed this as completed Apr 23, 2021
    @pitrou pitrou added the type-bug An unexpected behavior, bug, or error label Apr 23, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant