[Python-Dev] Strange error importing a Pickle from 2.7 to 3.2
Alexander Belopolsky
alexander.belopolsky at gmail.com
Wed Feb 23 20:16:24 CET 2011
On Tue, Feb 22, 2011 at 11:34 PM, Jesus Cea <jcea at jcea.es> wrote:
..
> Issue filed. It already has a patch. That was fast!. Now I can sit back
> waiting for 3.2.1 before touching my project again :). Mixed feelings
> about the waiting. I hope it is short.
It looks like you don't need delay your project: if you spell encoding
as "latin-1", your pickle loads just fine:
>>> with open("z.pickle", mode="rb") as f: pickle.load(f, encoding="latin-1")
...
{'ya_volcados': {'comment': ''}}
With encoding="latin1", it does fail:
>>> with open("z.pickle", mode="rb") as f: pickle.load(f, encoding="latin1")
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: operation forbidden on released memoryview object
(For those not following the tracker issue, the z.pickle file was
posted at <http://bugs.python.org/file20839/z.pickle>.)
There is still a bug, which is best demonstrated by
>>> pickle.loads(b'\x80\x02U\x00.', encoding='latin1')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: operation forbidden on released memoryview object
The fact that the above works with encoding='latin-1',
>>> pickle.loads(b'\x80\x02U\x00.', encoding='latin-1')
''
shows that there is probably more than one bug.
More information about the Python-Dev
mailing list