[Python-Dev] What to do for bytes in 2.6? (original) (raw)
Aahz aahz at pythoncraft.com
Sun Jan 20 15:56:59 CET 2008
- Previous message: [Python-Dev] What to do for bytes in 2.6?
- Next message: [Python-Dev] What to do for bytes in 2.6?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, Jan 19, 2008, Guido van Rossum wrote:
I believe that a constraint should be that by default (without -3 or a future import) str and bytes should be the same thing. Or, another way of looking at this, reads from binary files and reads from sockets (and other similar things, like ctypes and mmap and the struct module, for example) should return str instances, not instances of a str subclass by default -- IMO returning a subclass is bound to break too much code.
This makes perfect sense to me. And yet, I also like the idea that b""+u"" raises an exception. I have a suggestion, then: for 2.6, let's make bytes a subclass of string whose only difference is that it contains a flag. I don't care whether b""+u"" raises an exception. This should be enough for people on an accelerated 3.0 conversion schedule, and they can write their own test for the flag if they care.
For 2.7, we can start tightening up. b""+u"" can raise an exception, and the socket module might use a RETURN_BYTES variable.
To put it another way, I don't think we should consider 2.6 the stopping point for 2.x/3.x conversion help. There's nothing wrong with planning for features to go into 2.7 -- just as several PEPs in the past have had multi-version planning.
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"All problems in computer science can be solved by another level of
indirection." --Butler Lampson
- Previous message: [Python-Dev] What to do for bytes in 2.6?
- Next message: [Python-Dev] What to do for bytes in 2.6?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]