[3.7] bpo-22005: Fixed unpickling instances of datetime classes pickled by Python 2. (GH-11017) (GH-11022)
encoding='latin1' should be used for successful decoding.
(cherry picked from commit 8452ca15f41061c8a6297d7956df22ab476d4df4)
diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst
index 2b10ee2..52cbb62 100644
--- a/Doc/library/pickle.rst
+++ b/Doc/library/pickle.rst
@@ -235,6 +235,9 @@
*errors* tell pickle how to decode 8-bit string instances pickled by Python
2; these default to 'ASCII' and 'strict', respectively. The *encoding* can
be 'bytes' to read these 8-bit string instances as bytes objects.
+ Using ``encoding='latin1'`` is required for unpickling NumPy arrays and
+ instances of :class:`~datetime.datetime`, :class:`~datetime.date` and
+ :class:`~datetime.time` pickled by Python 2.
.. function:: loads(bytes_object, \*, fix_imports=True, encoding="ASCII", errors="strict")
@@ -252,6 +255,9 @@
*errors* tell pickle how to decode 8-bit string instances pickled by Python
2; these default to 'ASCII' and 'strict', respectively. The *encoding* can
be 'bytes' to read these 8-bit string instances as bytes objects.
+ Using ``encoding='latin1'`` is required for unpickling NumPy arrays and
+ instances of :class:`~datetime.datetime`, :class:`~datetime.date` and
+ :class:`~datetime.time` pickled by Python 2.
The :mod:`pickle` module defines three exceptions: