[Python-Dev] What to do for bytes in 2.6?

Christian Heimes lists at cheimes.de
Fri Jan 18 09:27:26 CET 2008


Guido van Rossum wrote:
> Oh, you won't. Just don't use the -3 command-line flag and don't put
> "from __future__ import <whatever>" at the top of your modules, and
> you won't have to change your ways at all. You can continue to
> distribute your packages in 2.5 syntax that will also work with 2.6,
> and your users will be happy (as long as they don't want to use your
> code on 3.0 -- but if you want to give them that, *that* is when you
> will finally be forced to face the issue. :-)

from __future__ import bytes ? What should the __future__ statement change?

* "" returns unicode instead of str
* b"" is allowed and returns bytes (a new subclass of str)
* u"" is still allowed and returns unicode, too.
* The str built-in is not available.

> Note that I believe that the -3 flag should not change semantics -- it
> should only add warnings. Semantic changes must either be backwards
> compatible or be requested explicitly with a __forward__ import (which
> 2to3 can remove).

Agreed! Should the -3 flag also warn about deprecated features which can
easily migrated with 2to3? In the past a warning for `` (back ticks)
were added. The feature is deprecated but the migration is very simple.

A 2to26 fixer may be worth implementing, too. It could migrate minor
changes like `` -> repr and "except egg, spam" -> "except egg as spam".

Christian



More information about the Python-Dev mailing list