[Python-Dev] PEP 460 reboot

Guido van Rossum guido at python.org
Mon Jan 13 04:45:13 CET 2014


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.

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list