str(bytes) in Python 3.0

John J. Lee jjl at pobox.com
Sat Apr 12 10:52:31 EDT 2008


Christian Heimes <lists at cheimes.de> writes:

> Gabriel Genellina schrieb:
>> On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii')  
>> above. But I get the same as repr(x) - is this on purpose?
>
> Yes, it's on purpose but it's a bug in your application to call str() on
> a bytes object or to compare bytes and unicode directly. Several months
> ago I added a bytes warning option to Python. Start Python as  "python
> -bb" and try it again. ;)

Why hasn't the one-argument str(bytes_obj) been designed to raise an
exception in Python 3?


John



More information about the Python-list mailing list