[Python-Dev] Compatibility between Python 2.3.x and Python 2.4.x

Fredrik Lundh fredrik at pythonware.com
Thu Sep 15 23:44:34 CEST 2005


(oops. trying again)

Rich Burridge wrote:

> I'm involved with the team that's working towards installing Python 2.4.x
> as part of a future release of the Solaris O/S.
>
> We currently have Python 2.3.x installed. We are trying to determine just
> how compatible these two release are (at both the binary and source levels).
>
> In other words, with Python 2.3.x .py, .pyc and .pyo files work correctly
> with Python 2.4.x ?

short answer: no

longer answer: most PY files work.  the exception is code that (accidentally
or intentionally) depends on implementation artifacts, undocumented behaviour
or bugs (see the changes documents for things that may affect your applications).

PYC and PYO files contain bytecode, and are not guaranteed to be portable
between different 2.X releases.

to check the bytecode revision used by a given Python interpreter, you can use
imp.get_magic():

Python 2.3.5
>>> import imp
>>> imp.get_magic()
';\xf2\r\n'

Python 2.4.1
>>> import imp
>>> imp.get_magic()
'm\xf2\r\n'

</F> 





More information about the Python-Dev mailing list