What is "marshal data"?

Cliff Wells logiplexsoftware at earthlink.net
Thu Nov 15 15:55:21 EST 2001


On Thursday 15 November 2001 11:24, Michael Hudson wrote:
> Cliff Wells <logiplexsoftware at earthlink.net> writes:
> > On Thursday 15 November 2001 10:28, Soren Ragsdale wrote:
> > > Possible sources of the problem: "uh.py" is imported from MANY
> > > programs on our network.  It's being imported by Linux and Irix
> > > machines running 1.5.2 and 2.1.1 versions of Python.  Could this be
> >
> > As mentioned in another thread, the bytecode between python versions is
> > not backward compatible, so you may be trying to execute 2.1.1 bytecode
> > on a 1.5.2 interpreter and that may be causing the problem.
>
> Shouldn't be.  The first four bytes of a .pyc file are a
> version-specific magic number, meant to stop this happening.
>
> Executing the wrong bytecode would cause SystemErrors or core dumps,
> not ValueErrors complaining about marshal data -- the marshal module
> does little checking of its input, as it's only there to speed things
> up...

So what is probably happening then is similar to what Soren originally 
suggested:  the different python versions read the .pyc, occasionally seeing 
that it isn't the correct bytecode version and so rewrite it, and it 
basically comes down to concurrency issues (one process rewriting the file 
while another is reading from it).  If this is the issue, then my suggestion 
for maintaining separate directories for each version should still resolve 
the problem.  Something else that may help would be to also pre-compile the 
.pyc files rather than doing it at runtime (he would still need to maintain 
separate directories for the different versions).

Regards,

-- 
Cliff Wells
Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308
(800) 735-0555 x308




More information about the Python-list mailing list