[Python-Dev] PEP 460 reboot

Ethan Furman ethan at stoneleaf.us
Mon Jan 13 04:56:06 CET 2014


On 01/12/2014 07:45 PM, Guido van Rossum wrote:
> On Sun, Jan 12, 2014 at 6:16 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
>> In reference to a byte stream, if you do:
>>
>> --> b'%s' % 'some text'.encode('cp1241')
>>
>> it's really just bytes into bytes.
>
> That's a confusing example -- it would be clearer to just show
>
> b'%s' % b'some text'
>
>> If you do :
>>
>> --> b'%s' % 'some text'
>>
>> then the encoding is ASCII with strict error checking.  So if it's not
>> representable as clean ASCII either encode it manually, or prepare for it to
>> blow up with an UnicodeEncodeError.
>
> You don't say what outcome you want, but if you wanted b'%s' % 'some
> text' to return b'some text' while b'%s' % '\u1234' should blow up,
> you're back at the Python 2 approach and that is the last thing I
> want.

Fair enough.  I'm cool with getting back b"'some_text'" and not ever blowing up.

--
~Ethan~


More information about the Python-Dev mailing list