Pickle translation
Skip Montanaro
skip at pobox.com
Wed Jul 11 16:55:45 EDT 2001
William> So, are there any tools to translate 1.5.2 pickles to 2.x
William> versions of the pickle format?
I wasn't aware that 2.x couldn't read pickles created by 1.5.2. I just
tried a simple example without any problem (sorry, 1.6 is as far as I go
back on my local machine):
% python1.6
Python 1.6 (#1, Jul 10 2001, 17:24:51) [GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux2
Copyright (c) 1995-2000 Corporation for National Research Initiatives.
All Rights Reserved.
Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved.
>>> class foo:
... pass
...
>>> a = foo()
>>> a.x = 1
>>> b = ["a",1,(0,1,2)]
>>> t = (a,b)
>>> d = {"key":t}
>>> d
{'key': (<__main__.foo instance at 8239bf8>, ['a', 1, (0, 1, 2)])}
>>> import pickle
>>> f = open("pickle.dat", "w")
>>> pickle.dump.__doc__
>>> pickle.dump(d, f)
>>> f.close()
>>>
% python2.1
Python 2.1.1c1 (#13, Jul 10 2001, 17:30:38)
[GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> class foo:
... pass
...
>>> import pickle
>>> d = pickle.load(open("pickle.dat"))
>>> d
{'key': (<__main__.foo instance at 0x82319cc>, ['a', 1, (0, 1, 2)])}
I see a comment in the pickle lib ref manual section about a change to
pickle's behavior that was introduced in 1.5b2 (significantly before 1.5.2),
but nothing about 1.5.2->2.x incompatibilities. Can you be more specific
about what's not working for you?
--
Skip Montanaro (skip at pobox.com)
(847)971-7098
More information about the Python-list
mailing list