[issue22549] bug in accessing bytes, inconsistent with normal strings and python 2.7

Kevin Hendricks report at bugs.python.org
Fri Oct 3 23:20:15 CEST 2014


Kevin Hendricks added the comment:

Thanks for letting me know this was expected behaviour.  I see the same "issue" holds true while using:

for c in b'0123456789':
   print(ord(c))
 
I ended up using slices nearly everyplace.  Still ran into iterator issues.  Horrible hack really.  

I think I will spend some time reading the python dev archives to figure out how anyone could defend this approach.

FWIW, introducing a bytes class that works exactly like byte (non-unicode strings) in python 2.X but disallowing any automatic up-conversion to full unicode (like during concatenation), would have been a useful step.  

I work on decoding binary formatted ebook files all of the time, and python 3's second class treatment of bytes makes no sense to me.  Perfectly valid code can be written using only utf-8 and latin-1 encoded bytestrings with no need to upconvert to anything.  It is practically impossible to support code like that in Python 3.

Boggles the mind.

Thanks again for the fast response.

Kevin

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22549>
_______________________________________


More information about the Python-bugs-list mailing list