This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: pickle is raising KeyError insteat of pickle.UnpicklingError under certain conditions
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.9
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: alexandre.vassalotti Nosy List: BTaskaya, Claudiu.Popa, Linus Pithan, alexandre.vassalotti, miss-islington
Priority: normal Keywords: patch

Created on 2019-11-21 11:22 by Linus Pithan, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 17335 merged Claudiu.Popa, 2019-11-22 10:00
Messages (3)
msg357159 - (view) Author: Linus Pithan (Linus Pithan) Date: 2019-11-21 11:22
When unpickling fails one would expect a pickle.UnpicklingError exception or at least a PickleError. However, when trying


it fails with KeyError: 980643429 which is not the wanted behaviour.
msg357167 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2019-11-21 13:08
It seems there are a couple of places in `_pickle.c` where we favour a `KeyError` instead of `UnpicklingError` such as 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.
msg357408 - (view) Author: miss-islington (miss-islington) Date: 2019-11-24 19:15
New changeset 6f03b236c17c96bc9f8a004ffa7e7ae0542e9cac 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)
Date User Action Args
2022-04-11 14:59:23adminsetgithub: 83057
2019-11-24 20:45:53alexandre.vassalottisetstatus: open -> closed
assignee: alexandre.vassalotti
stage: patch review -> resolved
resolution: fixed
versions: - Python 3.7, Python 3.8
2019-11-24 19:15:11miss-islingtonsetnosy: + miss-islington
messages: + msg357408
2019-11-22 10:00:59Claudiu.Popasetkeywords: + patch
stage: patch review
pull_requests: + pull_request16819
2019-11-21 13:08:15Claudiu.Popasetnosy: + Claudiu.Popa
messages: + msg357167
2019-11-21 11:26:37BTaskayasetnosy: + alexandre.vassalotti, BTaskaya

versions: + Python 3.8, Python 3.9
2019-11-21 11:22:59Linus Pithancreate