harmful str(bytes)

Hallvard B Furuseth h.b.furuseth at usit.uio.no
Mon Oct 11 23:57:44 CEST 2010

Stefan Behnel writes:
>Hallvard B Furuseth, 11.10.2010 21:50:
>> Fine, so programs will have to do it themselves...
> Yes, they can finally handle bytes and Unicode data correctly and
> safely. Having byte data turn into Unicode strings unexpectedly makes
> the behaviour of your code hardly predictable and fairly error prone. In
> Python 3, it's now possible to do the conversion safely at well defined
> points in your code and rely on the runtime to bark at you when
> something slips through or is mistreated. Detecting errors early makes
> your code better.
> That's a huge improvement. It didn't come for free and the current
> Python 3 releases still have their rough edges. But there are few left
> and the situation is constantly improving. You can help out if you want.

I quite agree with most of that - just not about it being safe, see my
reply to Terry Reedy.  Hence my suggestion to change or disable
bytes.__str__.  And yes, I'll be submitting some fixes or bug reports.


More information about the Python-list mailing list