Python v3 question related to pickle/marshal

D

Detlev Offenbach

Hi,

is it possible to marshal or pickle a data structure using Python v3 and
unmarshal or unpickle it using Python v2. If it is possible, how do I
have to do it. Everything I tried resulted in an EOFError exception upon
unmarshalling/unpickling.

Regards,
Detlev
 
T

Tino Wildenhain

Detlev said:
Hi,

is it possible to marshal or pickle a data structure using Python v3 and
unmarshal or unpickle it using Python v2. If it is possible, how do I
have to do it. Everything I tried resulted in an EOFError exception upon
unmarshalling/unpickling.

Could you give the code of a minimal example how you tried?

Regards
Tino

PS: it would not hurt to end questions with a question mark ;-)
 
P

Peter Otten

Detlev said:
is it possible to marshal or pickle a data structure using Python v3 and
unmarshal or unpickle it using Python v2. If it is possible, how do I
have to do it. Everything I tried resulted in an EOFError exception upon
unmarshalling/unpickling.

It seems to work here, at least for simple data:

$ python3.0
Python 3.0 (r30:67503, Dec 4 2008, 11:26:28)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import pickle
pickle.dump(dict(a=1, b=[42], c="yadda"), open("tmp.p", "wb"), protocol=2)
$ python
Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:43)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.{u'a': 1, u'c': u'yadda', u'b': [42]}

Maybe you have incompatible data structures?

Peter
 
D

Detlev Offenbach

Tino said:
Could you give the code of a minimal example how you tried?

The problem is fixed. The bug was somewhere else making me believe the
pickled file couldn't be read.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top