2008-01-18

Transitioning from 2.6 to 3.0 is beginning to solidify

Guido began a discussion on python-dev earlier this week about how to backport the bytes type. This has led to some clarification on how he sees people transitioning their code which I figured some people might be interested in.

The current proposal on how to handle the bytes type is a good illustration of what the current plan is. Basically b'' and bytes will become direct aliases for '' and str, respectively. The idea is that instead of having to backport all of that code and worry about supporting it all at the C level, people get a simple way to syntactically state that they are moving (or have moved) code over for compatibility with 3.0. Makes our lives easier in terms of maintaining code while letting users have a simple transition.

And the use of the -3 flag has been clarified. Guido said he wants the flag to augment 2to3, not replicate what it does. That means that warnings raised by -3 should only be for stuff that 2to3 can't handle directly. That means that even if you code is warnings-free with the -3 flag turned on there is no guarantee your code will run properly as 2to3 will be needed to handle syntactic changes that you will not be warned about.

So where does that leave us in terms of expected steps to go from 2.6 code to 3.0? As of right now the steps look to be:

  1. Run your code with normal warnings turned on. You should have no warnings in your code, including PendingDeprecationWarnings. Completing this step will make sure your code is good for the 2.x line. You should be doing this even if you don't care about 3.0.
  2. Run with the -3 flag turned on. Any warnings that crop up now should also be dealt with. At this point your code should be syntactically written for 2.x but partially semantically ready for 3.0 (along with still working with 2.x).
  3. Run 2to3 on your code. This should make it mostly syntactically ready for 3.0.
  4. Run your unit tests. Any remaining porting issues should crop up at this point.
Obviously this is all a work-in-progress. Until 2.6 is out the door any of this could fluctuate. But I think it all looks reasonable.