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

Terry Reedy tjreedy at udel.edu
Fri Jan 18 06:30:37 CET 2008


"Guido van Rossum" <guido at python.org> wrote in message 
news:ca471dc20801172043l3356e04et9b8e807177230c6f at mail.gmail.com...
| Is it reading text or binary data from stream blah? We can't tell.  If
| it's meant to be reading text, 2to3 should leave it alone. But if it's
| meant to be reading binary data, 2to3 should change the string
| literals to bytes literals (b"" in this case). (If it's used for both,
| there's no hope.) As it stands, 2to3 hasn't a chance to decide what to
| do, so it will leave it alone -- but the "translated" code will be
| wrong if it was meant to be reading bytes.

It seems that the main purpose of adding bytes (as more or less a
synonym for str when used as bytes) is to aid 2to3 translation.
So I think I would favor it being part of a future import.

| 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).

Were you planning to make bytes a __future__ (or __forward__?) import?
I think making it so should satisfy Raymond's concerns.  Even if whatever
you eventually do is technically backwards compatible, he is suggesting 
that
conceptually, it is not.  I see some validity to that view.

tjr





More information about the Python-Dev mailing list