cPickle fix for Py3

This commit is contained in:
Mike Croucher 2015-03-02 19:43:26 +00:00
parent 6aca7c2765
commit 46fc08a448

View file

@ -110,7 +110,10 @@ class Pickleable(object):
it properly.
:param protocol: pickling protocol to use, python-pickle for details.
"""
import cPickle as pickle
try: #Py2
import cPickle as pickle
except ImportError: #Py3
import pickle
if isinstance(f, str):
with open(f, 'wb') as f:
pickle.dump(self, f, protocol)