Hi!
> The problem apparently boils down to the following:
> - Pickle the string '\x80\x1f' in Python-2
> - Try to load that pickle in Python-3 (it fails).
>
> Bummer!
Nils Bruin pointed me to
https://stackoverflow.com/questions/28218466/unpickling-a-python-2-object-with-python-3
The proposed solution there is to use pickle.load(<file>,
encoding='bytes'). The encoding keyword only exist in Python-3.
If I undestand correctly (and some basic tests confirm the following
statements):
- Python-2 can unpickle both pickles created with Python-2 and pickles created
with Python-3 can be read with Python-3
- Without `encoding='bytes'`, Python-3 can in general not unpickle any
pickle created with Python-2 that contains strings.
- With `encoding='bytes'`, Python-3 *can* unpickle a pickle created with
Python-2 containing strings, and it doesn't interfere with unpickling
a pickle created with Python-3.
So, I suggest that at #28444 we change sage.misc.persist so that it uses
pickle.load() with the `encoding` keyword in Python-3 and withou that
keyword in Python-2. Do the Python-3 experts agree that that approach
makes sense? Given that a Python-2 string corresponds to a Python-3
bytes, I think it does, but I am not an expert.
Best regards,
Simon