Hi! On 2019-09-02, Simon King <simon.k...@uni-jena.de> wrote: > 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 -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/qkl1dv%247bpp%241%40blaine.gmane.org.