Skip to content

Commit a46728a

Browse files
bpo-39426: Fix outdated default and highest protocols in docs (GH-18154)
Some portions of the pickle documentation hadn't been updated for the pickle protocol changes in Python 3.8 (new protocol 5, default protocol 4). This PR fixes those docs. https://bugs.python.org/issue39426 (cherry picked from commit e9652e8) Co-authored-by: Mark Dickinson <[email protected]>
1 parent 5654f83 commit a46728a

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

Lib/pickle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,9 @@ def __init__(self, file, protocol=None, *, fix_imports=True,
409409
"""This takes a binary file for writing a pickle data stream.
410410
411411
The optional *protocol* argument tells the pickler to use the
412-
given protocol; supported protocols are 0, 1, 2, 3 and 4. The
413-
default protocol is 4. It was introduced in Python 3.4, it is
414-
incompatible with previous versions.
412+
given protocol; supported protocols are 0, 1, 2, 3, 4 and 5.
413+
The default protocol is 4. It was introduced in Python 3.4, and
414+
is incompatible with previous versions.
415415
416416
Specifying a negative protocol version selects the highest
417417
protocol version supported. The higher the protocol used, the

Modules/_pickle.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4647,8 +4647,9 @@ _pickle.Pickler.__init__
46474647
This takes a binary file for writing a pickle data stream.
46484648
46494649
The optional *protocol* argument tells the pickler to use the given
4650-
protocol; supported protocols are 0, 1, 2, 3 and 4. The default
4651-
protocol is 3; a backward-incompatible protocol designed for Python 3.
4650+
protocol; supported protocols are 0, 1, 2, 3, 4 and 5. The default
4651+
protocol is 4. It was introduced in Python 3.4, and is incompatible
4652+
with previous versions.
46524653
46534654
Specifying a negative protocol version selects the highest protocol
46544655
version supported. The higher the protocol used, the more recent the
@@ -4680,7 +4681,7 @@ static int
46804681
_pickle_Pickler___init___impl(PicklerObject *self, PyObject *file,
46814682
PyObject *protocol, int fix_imports,
46824683
PyObject *buffer_callback)
4683-
/*[clinic end generated code: output=0abedc50590d259b input=bb886e00443a7811]*/
4684+
/*[clinic end generated code: output=0abedc50590d259b input=a7c969699bf5dad3]*/
46844685
{
46854686
_Py_IDENTIFIER(persistent_id);
46864687
_Py_IDENTIFIER(dispatch_table);
@@ -7633,8 +7634,8 @@ This is equivalent to ``Pickler(file, protocol).dump(obj)``, but may
76337634
be more efficient.
76347635
76357636
The optional *protocol* argument tells the pickler to use the given
7636-
protocol; supported protocols are 0, 1, 2, 3 and 4. The default
7637-
protocol is 4. It was introduced in Python 3.4, it is incompatible
7637+
protocol; supported protocols are 0, 1, 2, 3, 4 and 5. The default
7638+
protocol is 4. It was introduced in Python 3.4, and is incompatible
76387639
with previous versions.
76397640
76407641
Specifying a negative protocol version selects the highest protocol
@@ -7660,7 +7661,7 @@ static PyObject *
76607661
_pickle_dump_impl(PyObject *module, PyObject *obj, PyObject *file,
76617662
PyObject *protocol, int fix_imports,
76627663
PyObject *buffer_callback)
7663-
/*[clinic end generated code: output=706186dba996490c input=cfdcaf573ed6e46c]*/
7664+
/*[clinic end generated code: output=706186dba996490c input=5ed6653da99cd97c]*/
76647665
{
76657666
PicklerObject *pickler = _Pickler_New();
76667667

@@ -7703,8 +7704,8 @@ _pickle.dumps
77037704
Return the pickled representation of the object as a bytes object.
77047705
77057706
The optional *protocol* argument tells the pickler to use the given
7706-
protocol; supported protocols are 0, 1, 2, 3 and 4. The default
7707-
protocol is 4. It was introduced in Python 3.4, it is incompatible
7707+
protocol; supported protocols are 0, 1, 2, 3, 4 and 5. The default
7708+
protocol is 4. It was introduced in Python 3.4, and is incompatible
77087709
with previous versions.
77097710
77107711
Specifying a negative protocol version selects the highest protocol
@@ -7724,7 +7725,7 @@ into *file* as part of the pickle stream. It is an error if
77247725
static PyObject *
77257726
_pickle_dumps_impl(PyObject *module, PyObject *obj, PyObject *protocol,
77267727
int fix_imports, PyObject *buffer_callback)
7727-
/*[clinic end generated code: output=fbab0093a5580fdf input=9f334d535ff7194f]*/
7728+
/*[clinic end generated code: output=fbab0093a5580fdf input=e543272436c6f987]*/
77287729
{
77297730
PyObject *result;
77307731
PicklerObject *pickler = _Pickler_New();

Modules/clinic/_pickle.c.h

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)