[sage-devel] Re: Unpickling problem (backwards incompatibility) in Python 3

2019-09-02 Thread Simon King
PS: On 2019-09-03, Simon King wrote: > - Without `encoding='bytes'`, Python-3 can in general not unpickle any > pickle created with Python-2 that contains strings. Stated differently: Ostensibly, Python-2 str corresponds to Python-3 bytes, and Python-2 unicode corresponds to Python-3 str. But

[sage-devel] Re: Unpickling problem (backwards incompatibility) in Python 3

2019-09-02 Thread Simon King
Hi! On 2019-09-02, Simon King 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-obj

Re: [sage-devel] Re: Unpickling problem (backwards incompatibility) in Python 3

2019-09-02 Thread 'Julien Puydt' via sage-devel
Hi, Le 02/09/2019 à 22:43, Simon King a écrit : > AFAIK, what I need to unpickle my old data is a way to tell Python-3 > that it shall (at least temporarily) unpickle all strings as bytes, in > the sense that the pickled string  '\x80\x1f' should be understood as > b'\x80\x1f'. Is there a way? I t

[sage-devel] Re: Unpickling problem (backwards incompatibility) in Python 3

2019-09-02 Thread Simon King
On Monday, September 2, 2019 at 6:22:24 PM UTC+2, Simon King wrote: > > Also, if I understand the error message "UnicodeDecodeError: 'ascii' > codec can't decode byte 0x80 in position 0: ordinal not in range(128)" > correctly, it is an error in unpickling a string. And this, I believe, > can and

[sage-devel] Re: Unpickling problem (backwards incompatibility) in Python 3

2019-09-02 Thread Simon King
On 2019-09-02, Vincent Delecroix <20100.delecr...@gmail.com> wrote: > As discussed in > > https://groups.google.com/forum/#!topic/sage-devel/JuKzzgxDlmA > > Pickling/unpickling is not supposed to work accross Sage versions > (including the Python version you use). > > Is this what you are trying

[sage-devel] Re: Unpickling problem (backwards incompatibility) in Python 3

2019-09-02 Thread Simon King
On 2019-09-02, Simon King wrote: > Strangely, when I read the pickle as a string >open('path/to/file.sobj').read() > then it fails with a (different?) UnicodeError in Python-3. That's not the problem. However, I am not able to track down the problem myself. So, I'd appreciate help. I think I

[sage-devel] Re: Unpickling problem

2009-07-04 Thread davidloeffler
Patch is now up at: http://trac.sagemath.org/sage_trac/ticket/6462 David On Jul 4, 2:14 pm, davidloeffler wrote: > It is indeed a bit strange that OrderElement derives from > FieldElement. But my diagnosis was different: Parent classes that have > attributes which are Elements cause problems fo

[sage-devel] Re: Unpickling problem

2009-07-04 Thread davidloeffler
It is indeed a bit strange that OrderElement derives from FieldElement. But my diagnosis was different: Parent classes that have attributes which are Elements cause problems for the default Python unpickler. For instance, if X is an AbsoluteOrder, then loads(dumps(X)) works and equals X, *as long

[sage-devel] Re: Unpickling problem

2009-07-04 Thread William Stein
On Sat, Jul 4, 2009 at 1:25 PM, davidloeffler wrote: > > This is now #6462. > > (I have played with it a bit myself, and I can get pickling and > unpickling to work, by defining a __reduce__ function for orders, and > adjusting the __reduce__ function for number field elements; but now > the stand

[sage-devel] Re: Unpickling problem

2009-07-04 Thread davidloeffler
This is now #6462. (I have played with it a bit myself, and I can get pickling and unpickling to work, by defining a __reduce__ function for orders, and adjusting the __reduce__ function for number field elements; but now the standard x == loads(dumps(x)) test doesn't seem to work.) David On Ju