From 8452ca15f41061c8a6297d7956df22ab476d4df4 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Fri, 7 Dec 2018 13:42:10 +0200 Subject: bpo-22005: Fixed unpickling instances of datetime classes pickled by Python 2. (GH-11017) encoding='latin1' should be used for successful decoding. --- Doc/library/pickle.rst | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Doc/library') diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst index 4f9d3596b6..5fe49a013b 100644 --- a/Doc/library/pickle.rst +++ b/Doc/library/pickle.rst @@ -243,6 +243,9 @@ process more convenient: *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") @@ -260,6 +263,9 @@ process more convenient: *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: -- cgit v1.2.1