Use highest possible pickle protocol

This commit is contained in:
micbou authored and Dave Halter committed 2018-06-23 14:45:34 +02:00
1 parent ea71dedaa1
commit 282c6a2ba1
5 files changed
+59 -15

No files matched your search

+16 -5
View File
@@ -446,9 +446,6 @@ if sys.version_info[:2] == (3, 3):
pickle.loads = loads
_PICKLE_PROTOCOL = 2
def pickle_load(file):
try:
if is_py3:
@@ -462,9 +459,9 @@ def pickle_load(file):
raise
def pickle_dump(data, file):
def pickle_dump(data, file, protocol):
try:
pickle.dump(data, file, protocol=_PICKLE_PROTOCOL)
pickle.dump(data, file, protocol)
# On Python 3.3 flush throws sometimes an error even though the writing
# operation should be completed.
file.flush()
@@ -476,6 +473,20 @@ def pickle_dump(data, file):
raise
# Determine the highest protocol version compatible for a given list of Python
# versions.
def highest_pickle_protocol(python_versions):
protocol = 4
for version in python_versions:
if version[0] == 2:
# The minimum protocol version for the versions of Python that we
# support (2.7 and 3.3+) is 2.
return 2
if version[1] < 4:
protocol = 3
return protocol
try:
from inspect import Parameter
except ImportError: