If a Python 3 class is pickled using protocol 2, it is supposed to work in Python 2, but unfortunately, this fails because the names of some classes have changed.
Assume we have code called as follows.
Sender
pickle.dumps(obj,2)
Receiver
pickle.loads(atom)
To give a specific case, if obj={}
, then the error given is:
ImportError: No module named builtins
This is because Python 2 uses __builtin__
instead.
The question is the best way to fix this problem.