Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e9652e8

Browse files
mdickinsonmiss-islington
authored andcommitted
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
1 parent b9783d2 commit e9652e8

3 files changed

Lines changed: 21 additions & 19 deletions

File tree

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
@@ -4645,8 +4645,9 @@ _pickle.Pickler.__init__
46454645
This takes a binary file for writing a pickle data stream.
46464646
46474647
The optional *protocol* argument tells the pickler to use the given
4648-
protocol; supported protocols are 0, 1, 2, 3 and 4. The default
4649-
protocol is 3; a backward-incompatible protocol designed for Python 3.
4648+
protocol; supported protocols are 0, 1, 2, 3, 4 and 5. The default
4649+
protocol is 4. It was introduced in Python 3.4, and is incompatible
4650+
with previous versions.
46504651
46514652
Specifying a negative protocol version selects the highest protocol
46524653
version supported. The higher the protocol used, the more recent the
@@ -4678,7 +4679,7 @@ static int
46784679
_pickle_Pickler___init___impl(PicklerObject *self, PyObject *file,
46794680
PyObject *protocol, int fix_imports,
46804681
PyObject *buffer_callback)
4681-
/*[clinic end generated code: output=0abedc50590d259b input=bb886e00443a7811]*/
4682+
/*[clinic end generated code: output=0abedc50590d259b input=a7c969699bf5dad3]*/
46824683
{
46834684
_Py_IDENTIFIER(persistent_id);
46844685
_Py_IDENTIFIER(dispatch_table);
@@ -7635,8 +7636,8 @@ This is equivalent to ``Pickler(file, protocol).dump(obj)``, but may
76357636
be more efficient.
76367637
76377638
The optional *protocol* argument tells the pickler to use the given
7638-
protocol; supported protocols are 0, 1, 2, 3 and 4. The default
7639-
protocol is 4. It was introduced in Python 3.4, it is incompatible
7639+
protocol; supported protocols are 0, 1, 2, 3, 4 and 5. The default
7640+
protocol is 4. It was introduced in Python 3.4, and is incompatible
76407641
with previous versions.
76417642
76427643
Specifying a negative protocol version selects the highest protocol
@@ -7662,7 +7663,7 @@ static PyObject *
76627663
_pickle_dump_impl(PyObject *module, PyObject *obj, PyObject *file,
76637664
PyObject *protocol, int fix_imports,
76647665
PyObject *buffer_callback)
7665-
/*[clinic end generated code: output=706186dba996490c input=cfdcaf573ed6e46c]*/
7666+
/*[clinic end generated code: output=706186dba996490c input=5ed6653da99cd97c]*/
76667667
{
76677668
PicklerObject *pickler = _Pickler_New();
76687669

@@ -7705,8 +7706,8 @@ _pickle.dumps
77057706
Return the pickled representation of the object as a bytes object.
77067707
77077708
The optional *protocol* argument tells the pickler to use the given
7708-
protocol; supported protocols are 0, 1, 2, 3 and 4. The default
7709-
protocol is 4. It was introduced in Python 3.4, it is incompatible
7709+
protocol; supported protocols are 0, 1, 2, 3, 4 and 5. The default
7710+
protocol is 4. It was introduced in Python 3.4, and is incompatible
77107711
with previous versions.
77117712
77127713
Specifying a negative protocol version selects the highest protocol
@@ -7726,7 +7727,7 @@ into *file* as part of the pickle stream. It is an error if
77267727
static PyObject *
77277728
_pickle_dumps_impl(PyObject *module, PyObject *obj, PyObject *protocol,
77287729
int fix_imports, PyObject *buffer_callback)
7729-
/*[clinic end generated code: output=fbab0093a5580fdf input=9f334d535ff7194f]*/
7730+
/*[clinic end generated code: output=fbab0093a5580fdf input=e543272436c6f987]*/
77307731
{
77317732
PyObject *result;
77327733
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)