]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-122311: Improve and unify pickle errors (GH-122771)
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 9 Sep 2024 12:04:51 +0000 (15:04 +0300)
committerGitHub <noreply@github.com>
Mon, 9 Sep 2024 12:04:51 +0000 (15:04 +0300)
commitb2a8c38bb20e0a201bbc60f66371ee4e406f6dae
tree721276e0bdc3ad23a2a0d4d5e58c9b7de59b9423
parent32bc2d61411fb71bdc84eb29c6859517e7f25f36
gh-122311: Improve and unify pickle errors (GH-122771)

* Raise PicklingError instead of UnicodeEncodeError, ValueError
  and AttributeError in both implementations.
* Chain the original exception to the pickle-specific one as __context__.
* Include the error message of ImportError and some AttributeError in
  the PicklingError error message.
* Unify error messages between Python and C implementations.
* Refer to documented __reduce__ and __newobj__ callables instead of
  internal methods (e.g. save_reduce()) or pickle opcodes (e.g. NEWOBJ).
* Include more details in error messages (what expected, what got).
* Avoid including a potentially long repr of an arbitrary object in
  error messages.
Lib/pickle.py
Lib/test/pickletester.py
Misc/NEWS.d/next/Library/2024-08-07-11-57-41.gh-issue-122311.LDExnJ.rst [new file with mode: 0644]
Modules/_pickle.c