Python 3

Robert Collins robertc at robertcollins.net
Tue Jun 22 23:54:06 BST 2010


We could - barely - consider dropping 2.4 (note that the oldest
supported RHEL, as I understand it, is still python 2.3 only).

I'm very sure we would be shooting ourselves in the foot to drop 2.5.

As for the extension guidelines, 'meh'. For reference they are:
--
For porting existing Python 2.5 or 2.6 source code to Python 3.0, the
best strategy is the following:

(Prerequisite:) Start with excellent test coverage.
Port to Python 2.6. This should be no more work than the average port
from Python 2.x to Python 2.(x+1). Make sure all your tests pass.
(Still using 2.6:) Turn on the -3 command line switch. This enables
warnings about features that will be removed (or change) in 3.0. Run
your test suite again, and fix code that you get warnings about until
there are no warnings left, and all your tests still pass.
Run the 2to3 source-to-source translator over your source code tree.
(See 2to3 - Automated Python 2 to 3 code translation for more on this
tool.) Run the result of the translation under Python 3.0. Manually
fix up any remaining issues, fixing problems until all tests pass
again.
It is not recommended to try to write source code that runs unchanged
under both Python 2.6 and 3.0; you’d have to use a very contorted
coding style, e.g. avoiding print statements, metaclasses, and much
more. If you are maintaining a library that needs to support both
Python 2.6 and Python 3.0, the best approach is to modify step 3 above
by editing the 2.6 version of the source code and running the 2to3
translator again, rather than editing the 3.0 version of the source
code.
--

We haven't really ignored them - we are ported to 2.6, we have
fantastic test coverage. Folk who are doing Python 3 work can use the
-3 switch; I'm interested here in how we enable those folk to have an
easy life, not in the mechanics of actually doing the work - that is a
separate, albeit related, problem.
2to3 is a problem for us. Here's the problem:
 - folk will want 3 before there are no platforms that have python2.x
and not python3.x support.
 - 2to3 means an indeterministic program is actually run
 - I like to be able to properly support things
 - distros would prefer to ship a single 'bzr' package rather than two
separate ones - and because they run with precompiled files not
writable by the user...

python2to3 is essentially useless to us. IMNSHO. Its a great tool for
understanding *the first pass* of what needs to be changed, but not
for actually having a supported result.

As for the 'not recommended' clause - the *Python 3* release manager
has submitted patches to another project - testtools - that does
precisely that, a single source that works. And its actually pretty
nice.

-Rob



More information about the bazaar mailing list