mirror of
https://github.com/python/cpython.git
synced 2025-12-04 08:34:25 +00:00
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.
This commit is contained in:
parent
32bc2d6141
commit
b2a8c38bb2
4 changed files with 249 additions and 223 deletions
|
|
@ -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.
|
||||
Loading…
Add table
Add a link
Reference in a new issue