diff options
author | Zackery Spytz <zspytz@gmail.com> | 2020-10-29 09:44:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-29 09:44:35 (GMT) |
commit | df59273c7a384ea8c890fa8e9b80c92825df841c (patch) | |
tree | a2d465e633a7d73df8741923d8901f0f0411f09e /Doc/library/shelve.rst | |
parent | 4173320920706b49a004bdddd8d7108e8984e3fc (diff) | |
download | cpython-df59273c7a384ea8c890fa8e9b80c92825df841c.zip cpython-df59273c7a384ea8c890fa8e9b80c92825df841c.tar.gz cpython-df59273c7a384ea8c890fa8e9b80c92825df841c.tar.bz2 |
bpo-34204: Use pickle.DEFAULT_PROTOCOL in shelve (GH-19639)
Use pickle.DEFAULT_PROTOCOL (currently 5) in shelve instead of a
hardcoded 3.
Diffstat (limited to 'Doc/library/shelve.rst')
-rw-r--r-- | Doc/library/shelve.rst | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Doc/library/shelve.rst b/Doc/library/shelve.rst index f08c581..07caf91 100644 --- a/Doc/library/shelve.rst +++ b/Doc/library/shelve.rst @@ -25,8 +25,9 @@ lots of shared sub-objects. The keys are ordinary strings. database file is opened for reading and writing. The optional *flag* parameter has the same interpretation as the *flag* parameter of :func:`dbm.open`. - By default, version 3 pickles are used to serialize values. The version of the - pickle protocol can be specified with the *protocol* parameter. + By default, pickles created with :data:`pickle.DEFAULT_PROTOCOL` are used + to serialize values. The version of the pickle protocol can be specified + with the *protocol* parameter. Because of Python semantics, a shelf cannot know when a mutable persistent-dictionary entry is modified. By default modified objects are @@ -40,6 +41,10 @@ lots of shared sub-objects. The keys are ordinary strings. determine which accessed entries are mutable, nor which ones were actually mutated). + .. versionchanged:: 3.10 + :data:`pickle.DEFAULT_PROTOCOL` is now used as the default pickle + protocol. + .. note:: Do not rely on the shelf being closed automatically; always call @@ -108,9 +113,10 @@ Restrictions A subclass of :class:`collections.abc.MutableMapping` which stores pickled values in the *dict* object. - By default, version 3 pickles are used to serialize values. The version of the - pickle protocol can be specified with the *protocol* parameter. See the - :mod:`pickle` documentation for a discussion of the pickle protocols. + By default, pickles created with :data:`pickle.DEFAULT_PROTOCOL` are used + to serialize values. The version of the pickle protocol can be specified + with the *protocol* parameter. See the :mod:`pickle` documentation for a + discussion of the pickle protocols. If the *writeback* parameter is ``True``, the object will hold a cache of all entries accessed and write them back to the *dict* at sync and close times. @@ -130,6 +136,10 @@ Restrictions .. versionchanged:: 3.4 Added context manager support. + .. versionchanged:: 3.10 + :data:`pickle.DEFAULT_PROTOCOL` is now used as the default pickle + protocol. + .. class:: BsdDbShelf(dict, protocol=None, writeback=False, keyencoding='utf-8') |