summaryrefslogtreecommitdiffstats
path: root/Misc/NEWS.d/next
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2024-09-09 12:04:51 (GMT)
committerGitHub <noreply@github.com>2024-09-09 12:04:51 (GMT)
commitb2a8c38bb20e0a201bbc60f66371ee4e406f6dae (patch)
tree721276e0bdc3ad23a2a0d4d5e58c9b7de59b9423 /Misc/NEWS.d/next
parent32bc2d61411fb71bdc84eb29c6859517e7f25f36 (diff)
downloadcpython-b2a8c38bb20e0a201bbc60f66371ee4e406f6dae.zip
cpython-b2a8c38bb20e0a201bbc60f66371ee4e406f6dae.tar.gz
cpython-b2a8c38bb20e0a201bbc60f66371ee4e406f6dae.tar.bz2
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.
Diffstat (limited to 'Misc/NEWS.d/next')
-rw-r--r--Misc/NEWS.d/next/Library/2024-08-07-11-57-41.gh-issue-122311.LDExnJ.rst5
1 files changed, 5 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2024-08-07-11-57-41.gh-issue-122311.LDExnJ.rst b/Misc/NEWS.d/next/Library/2024-08-07-11-57-41.gh-issue-122311.LDExnJ.rst
new file mode 100644
index 0000000..07ade20
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-08-07-11-57-41.gh-issue-122311.LDExnJ.rst
@@ -0,0 +1,5 @@
+Improve errors in the :mod:`pickle` module. :exc:`~pickle.PicklingError` is
+now raised more often instead of :exc:`UnicodeEncodeError`,
+:exc:`ValueError` and :exc:`AttributeError`, and the original exception is
+chained to it. Improve and unify error messages in Python and C
+implementations.