How do I use a pyc file created with an older version of Python?
Michael Hudson
mwh21 at cam.ac.uk
Mon Feb 12 12:27:39 EST 2001
Paul Moore <paul.moore at uk.origin-it.com> writes:
> 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?
The reason the magic number is different is because the code is not
compatible.
> Or would I need to "upgrade" the marshalled code somehow? Or is this
> not possible, and I just have to get the source back...?
Getting the source back is your only real hope. I suppose it would be
possible to write a 1.5.2 -> 2.0 bytecode translator (the differences
aren't all that great), but it doesn't seem worth the effort (to me,
at least).
There's also decompyle (google for it) that may, or may not, be able
to translate your .pyc into a .py.
Cheers,
M.
--
You owe The Oracle a TV with an 'intelligence' control - I've tried
'brightness' but that didn't work.
-- Internet Oracularity #1192-01
More information about the Python-list
mailing list