How do I use a pyc file created with an older version of Python?

Paul Moore paul.moore at uk.origin-it.com
Mon Feb 12 12:03:55 EST 2001


Hi,
This is probably a silly question, but I have an old pyc file
generated under Python 1.5.? (I think), and I now use Python 2.0. I
don't have the source easily accessible, unortunately, and I don't
really want to install Python 1.5 as well, just for this one bit of
code.

Is it possible to convert a pyc from an older version of Python to a
newer one, without the source? It seems like it should be possible, as
a pyc is (I believe) just a magic number plus a marshalled code
object. Assuming the code itself is compatible, could I just "fix" the
magic number? Or would I need to "upgrade" the marshalled code
somehow? Or is this not possible, and I just have to get the source
back...?

Thanks,
Paul




More information about the Python-list mailing list