[Python-checkins] peps: PEP 495: New pickle format.

alexander.belopolsky python-checkins at python.org
Mon Sep 21 05:18:42 CEST 2015


https://hg.python.org/peps/rev/f39bcfcb6db8
changeset:   6083:f39bcfcb6db8
user:        Alexander Belopolsky <alexander.belopolsky at gmail.com>
date:        Sun Sep 20 23:17:33 2015 -0400
summary:
  PEP 495: New pickle format.

files:
  pep-0495.txt |  16 ++++++++++------
  1 files changed, 10 insertions(+), 6 deletions(-)


diff --git a/pep-0495.txt b/pep-0495.txt
--- a/pep-0495.txt
+++ b/pep-0495.txt
@@ -288,14 +288,18 @@
 Pickles
 .......
 
+The value of the fold attribute will only be saved in pickles created
+with protocol version 4 (introduced in Python 3.4) or greater.
+
 Pickle sizes for the ``datetime.datetime`` and ``datetime.time``
 objects will not change.  The ``fold`` value will be encoded in the
-first bit of the 5th byte of the ``datetime.datetime`` pickle payload
-or the 2nd byte of the datetime.time. In the `current implementation`_
-these bytes are used to store minute value (0-59) and the first bit is
-always 0.  (This change only affects pickle format.  In the C
-implementation, the ``fold`` attribute will get a full byte to store its
-value.)
+first bit of the 3rd (1st) byte of ``datetime.datetime``
+(``datetime.time``) pickle payload.  In the `current implementation`_
+these byte are used to store the month (1-12) and hour (0-23) values
+and the first bit is always 0.  We picked these bytes because they are
+the only bytes that are checked by the current unpickle code.  Thus
+loading post-PEP ``fold=1`` pickles in a pre-PEP Python will result in
+an exception rather than an instance with out of range components.
 
 .. _current implementation: https://hg.python.org/cpython/file/d3b20bff9c5d/Include/datetime.h#l17
 

-- 
Repository URL: https://hg.python.org/peps


More information about the Python-checkins mailing list