Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3312,6 +3312,16 @@ Changes in the Python API
This temporary change affects other threads.
(Contributed by Serhiy Storchaka in :gh:`69998`.)

* :func:`pickle.dump` and :func:`pickle.dumps` now raise
:exc:`~pickle.PicklingError` for some failures that previously raised
:exc:`AttributeError`, :exc:`ImportError`, :exc:`ValueError`,
:exc:`UnicodeEncodeError` or :exc:`!PicklingError`,
depending on the implementation
Comment on lines +3316 to +3319

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit confusing to say that we raise PicklingError instead of... previously PicklingError. I think you can omit the second PicklingError.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep it for correctness. Depending on implementation, different types were raised, including PicklingError. And this was inconsistent -- for one kind of error you could get PicklingError in C and AttributeError in Python, for other -- UnicodeEncodeError in C and PicklingError in Python.

(for example, pickling a local object, or an object whose module cannot be imported).
The original exception is chained to the :exc:`!PicklingError`.
Code that caught these exceptions should also catch :exc:`!PicklingError`.
(Contributed by Serhiy Storchaka in :gh:`122311`.)

* :class:`types.UnionType` is now an alias for :class:`typing.Union`,
causing changes in some behaviors.
See :ref:`above <whatsnew314-typing-union>` for more details.
Expand Down
Loading