Merge pull request #4385 from kayahans/develop

Nexus: Handle pickle protocols between python versions
This commit is contained in:
Ye Luo 2023-01-08 11:04:42 -06:00 committed by GitHub
commit 89f64e07e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -443,7 +443,19 @@ class object_interface(object):
try:
tmp = pickle.load(fobj)
except:
tmp = pickle.load(fobj,encoding='latin1')
try:
tmp = pickle.load(fobj,encoding='latin1')
except:
# fallback for files created with protocol 5
# in environments that only support up to protocol 4
try:
import pickle5
tmp = pickle5.load(fobj)
except ImportError:
have_pickle5 = False
error("Highest pickle protocol in current python version is {}, but {} is written using a higher protocol. Install pickle5, e.g. via pip, to enable protocol 5 in python <= 3.7.x".format(pickle.HIGHEST_PROTOCOL, fpath))
#end try
#end try
#end try
fobj.close()
d = self.__dict__