Skip to content

Yes, Python 2.6 is backwards compatible!

February 12, 2010

I’ve now seen three separate cases of people claiming or implying that Python 2.6 isn’t compatible with Python 2.5 and that some sort of porting effort would be needed. Let me make this perfectly clear: The people who claim this do not know what they are talking about, and has most likely never even tried to run their software on Python 2.6!

I have no idea where this rumour comes from but it’s utterly false. The incompatibilities between 2.5 and 2.6 are no greater than between 2.4 and 2.5 or 2.4 and 2.3. In fact they are smaller. The main incompatibility is that you no longer in Python 2.6 can raise string exceptions and you can’t call a variable “with”. But Python 2.5 warns for both these changes, so anyone running on Python 2.5 is likely to have fixed this already, as the deprecation warnings are pretty annoying.

Now, there are big changes in Python 2.6, but those are all about new features and forward compatibility. You no longer have to use a __future__ import for the with statement, you can use the new syntax when catching exceptions, the multiprocessing and json modules are new, there are several new __future__ imports for increased compatibility with Python 3, etc. But none of these break backwards compatibility. The only changes that do so will give a deprecation warning in Python 2.5, and as such it’s actually more backwards compatible that Python 2.5 was with 2.4, as less things break.

Python 2.6 is in fact the most compatible Python version ever, excluding the upcoming 2.7 which well have some additional Python 3 features backported. Python 2.6 can not only run most Python 1 and Python 2 code, but even quite a lot of Python 3 code too, if you add some __future__ imports.

So there. I hope this cleared things up.

About these ads
3 Comments
  1. Gunnar Thielebein permalink

    Hi,

    is just saw your blog entry when looking for some further information on plone setup.
    With your statement about backwards compatibility in mind I wonder why plone does depend on python2.4 so strictly (already aborting in installer).

    If python2.5 *is* backwards compatible I don’t see any problems getting plone running with 2.5.

    May you clarify that for me?

  2. Yes.

    First of all I wrote 2.6, not 2.5.

    Second of all the only way to achieve 100% backwards compatibility is to not change *anything*. Even bugfixes will change the way things behave, and if you have written code relying on a bugfix, then of course that bugfix means it’s no longer backwards compatible. In this context “backwards compatibility” means that the changes you need are trivial and that you do not have to drop the support of previous versions. In contrast, Python 3 is *not* backwards compatible, as the syntax has changed in such a way that you can’t run the same code under both versions without resorting to special trickery to get around the problems. Basically, if you want the code to run unmodified on Python 2 and Python 3 you can not use all the features of Python 2. *Not* compatible. But there is no problem to use all the features of Python 2.5 and still run the code on Python 2.6. So that *is* backwards compatible.

    Thirdly, 2.5 has more incompatible changes than 2.6.

    Four, Plone requires Python 2.4, because it runs on Zope 2.10 which requires 2.4. Zope does that because Zope relies on internals of Python to do some of the advanced things like security. These means that we can’t support Zope on a new version of Python without making a security review to make sure that Python hasn’t broken the security in subtle ways that open security holes. At the release time of the first beta of Zope 2.10.0 the final version of Python 2.5 had not been released. Zope 2.10 thus used the last available Python version at that time: 2.4. There was also other changes like the use of variables called “with” that failed under Python 2.5.

    I hope this clarifies things.

  3. As for anonymous people commenting here claiming that the article is wrong, if they leave their real name and email address I might be inclined to explain things to them.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,225 other followers

%d bloggers like this: