bpo-34204: Use pickle.DEFAULT_PROTOCOL in shelve (GH-19639)

Use pickle.DEFAULT_PROTOCOL (currently 5) in shelve instead of a
hardcoded 3.
This commit is contained in:
Zackery Spytz 2020-10-29 03:44:35 -06:00 committed by GitHub
parent 4173320920
commit df59273c7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 8 deletions

View file

@ -56,7 +56,7 @@ entries in the cache, and empty the cache (d.sync() also synchronizes
the persistent dictionary on disk, if feasible).
"""
from pickle import Pickler, Unpickler
from pickle import DEFAULT_PROTOCOL, Pickler, Unpickler
from io import BytesIO
import collections.abc
@ -85,7 +85,7 @@ class Shelf(collections.abc.MutableMapping):
keyencoding="utf-8"):
self.dict = dict
if protocol is None:
protocol = 3
protocol = DEFAULT_PROTOCOL
self._protocol = protocol
self.writeback = writeback
self.cache = {}