[fix] Pickle need binary mode

This commit is contained in:
ljf 2018-10-05 11:37:17 +02:00
parent 812cd37822
commit 4432e22412

View file

@ -388,7 +388,7 @@ class ActionsMap(object):
if use_cache and os.path.exists(actionsmap_pkl): if use_cache and os.path.exists(actionsmap_pkl):
try: try:
# Attempt to load cache # Attempt to load cache
with open(actionsmap_pkl) as f: with open(actionsmap_pkl, 'rb') as f:
actionsmaps[n] = pickle.load(f) actionsmaps[n] = pickle.load(f)
# TODO: Switch to python3 and catch proper exception # TODO: Switch to python3 and catch proper exception
except (IOError, EOFError): except (IOError, EOFError):
@ -554,7 +554,7 @@ class ActionsMap(object):
pkl = '%s-%d-%d.pkl' % (n, am_file_stat.st_size, am_file_stat.st_mtime) pkl = '%s-%d-%d.pkl' % (n, am_file_stat.st_size, am_file_stat.st_mtime)
with open_cachefile(pkl, 'w', subdir='actionsmap') as f: with open_cachefile(pkl, 'wb', subdir='actionsmap') as f:
pickle.dump(actionsmaps[n], f) pickle.dump(actionsmaps[n], f)
return actionsmaps return actionsmaps