id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,merged,author,reviewer,upstream,work_issues,branch,commit,dependencies,stopgaps
28444,Fix backwards incompatibility of unpickling in Python 3,SimonKing,,"EDIT: In the original ticket description, I stated: ""I believe that a backwards incompatible change of pickling is a blocker for Python-3 support."" In that (and ONLY in that) sense I believe this ticket is a blocker. I replaced the original ticket description by something that I wrote in a comment, because now I have a much smaller example, and moreover pickles of the same object created with Python-3 and with Python-2, so that one can compare.
The following examples require the optional meataxe package, but I am not sure yet if meataxe is to blame or Python-3 (I hope it is the former, because I guess it would be more easy to fix).
attachment:Py2.sobj and attachment:Py3.sobj result in the following behaviour in Python-3
{{{
sage: load('/home/king/Projekte/coho/tests/Py2.sobj')
---------------------------------------------------------------------------
UnicodeDecodeError Traceback (most recent call last)
in ()
----> 1 load('/home/king/Projekte/coho/tests/Py2.sobj')
/home/king/Sage/git/py3/local/lib/python3.7/site-packages/sage/misc/persist.pyx in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2824)()
149
150 ## Load file by absolute filename
--> 151 with open(filename, 'rb') as fobj:
152 X = loads(fobj.read(), compress=compress)
153 try:
/home/king/Sage/git/py3/local/lib/python3.7/site-packages/sage/misc/persist.pyx in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2774)()
150 ## Load file by absolute filename
151 with open(filename, 'rb') as fobj:
--> 152 X = loads(fobj.read(), compress=compress)
153 try:
154 X._default_filename = os.path.abspath(filename)
/home/king/Sage/git/py3/local/lib/python3.7/site-packages/sage/misc/persist.pyx in sage.misc.persist.loads (build/cythonized/sage/misc/persist.c:7270)()
967
968 unpickler = SageUnpickler(io.BytesIO(s))
--> 969 return unpickler.load()
970
971
UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 0: ordinal not in range(128)
sage: load('/home/king/Projekte/coho/tests/Py3.sobj')
[1 0 0 0 0 0 0 0]
[0 0 0 1 1 1 1 1]
}}}
and in Python-2
{{{
sage: load('/home/king/Projekte/coho/tests/Py2.sobj')
[1 0 0 0 0 0 0 0]
[0 0 0 1 1 1 1 1]
sage: load('/home/king/Projekte/coho/tests/Py3.sobj')
[1 0 0 0 0 0 0 0]
[0 0 0 1 1 1 1 1]
sage: __ == _
True
}}}
So, the Python-3 pickle can be unpickled in Python-2, but not the other way around. What is the problem?",defect,closed,blocker,sage-8.9,python3,fixed,unpickling UnicodeError backwards compatibility,,,Simon King,Nils Bruin,N/A,,d7f170f2a2b8371da13d5577770b80868b21a726,,,