Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nexus: Handle pickle protocols between python versions #4385

Merged
merged 4 commits into from
Jan 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion nexus/lib/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,19 @@ def load(self,fpath=None):
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__
Expand Down