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 is raising KeyError insteat of pickle.UnpicklingError under certain conditions #83057

Closed
LinusPithan mannequin opened this issue Nov 21, 2019 · 3 comments
Closed
Assignees
Labels
3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@LinusPithan
Copy link
Mannequin

LinusPithan mannequin commented Nov 21, 2019

BPO 38876
Nosy @avassalotti, @PCManticore, @miss-islington, @isidentical
PRs
  • bpo-38876: Raise pickle.UnpicklingError when loading an item from memo for invalid input #17335
  • 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 = 'https://github.com/avassalotti'
    closed_at = <Date 2019-11-24.20:45:53.146>
    created_at = <Date 2019-11-21.11:22:59.127>
    labels = ['type-bug', 'library', '3.9']
    title = 'pickle is raising KeyError insteat of pickle.UnpicklingError under certain conditions'
    updated_at = <Date 2019-11-24.20:45:53.144>
    user = 'https://bugs.python.org/LinusPithan'

    bugs.python.org fields:

    activity = <Date 2019-11-24.20:45:53.144>
    actor = 'alexandre.vassalotti'
    assignee = 'alexandre.vassalotti'
    closed = True
    closed_date = <Date 2019-11-24.20:45:53.146>
    closer = 'alexandre.vassalotti'
    components = ['Library (Lib)']
    creation = <Date 2019-11-21.11:22:59.127>
    creator = 'Linus Pithan'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38876
    keywords = ['patch']
    message_count = 3.0
    messages = ['357159', '357167', '357408']
    nosy_count = 5.0
    nosy_names = ['alexandre.vassalotti', 'Claudiu.Popa', 'miss-islington', 'BTaskaya', 'Linus Pithan']
    pr_nums = ['17335']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue38876'
    versions = ['Python 3.9']

    @LinusPithan
    Copy link
    Mannequin Author

    LinusPithan mannequin commented Nov 21, 2019

    When unpickling fails one would expect a pickle.UnpicklingError exception or at least a PickleError. However, when trying

    pickle.loads(b"jens:")

    it fails with KeyError: 980643429 which is not the wanted behaviour.

    @LinusPithan LinusPithan mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Nov 21, 2019
    @isidentical isidentical added 3.8 only security fixes 3.9 only security fixes labels Nov 21, 2019
    @PCManticore
    Copy link
    Mannequin

    PCManticore mannequin commented Nov 21, 2019

    It seems there are a couple of places in _pickle.c where we favour a KeyError instead of UnpicklingError such as https://github.com/python/cpython/blob/master/Modules/_pickle.c#L6178. From a quick debugging it seems it originates in load_long_binget.

    Ideally those places should return UnpicklingError instead, not sure why a KeyError was preferred. Happy to submit a patch if that's a change that makes sense.

    @miss-islington
    Copy link
    Contributor

    New changeset 6f03b23 by Miss Islington (bot) (Claudiu Popa) in branch 'master':
    bpo-38876: Raise pickle.UnpicklingError when loading an item from memo for invalid input (GH-17335)
    6f03b23

    @avassalotti avassalotti removed 3.7 (EOL) end of life 3.8 only security fixes labels Nov 24, 2019
    @avassalotti avassalotti self-assigned this Nov 24, 2019
    @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.9 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

    3 participants