Nick Coghlan wrote:

On 13 Jan 2014 01:22, "Kristján Valur Jónsson" <krist...@ccpgames.com <mailto:krist...@ccpgames.com>> wrote:

> Well, my suggestion would that we _should_ make it work, by having the %s format specifyer on bytes objects mean: str(arg).encode('ascii', 'strict')
>
It is not explicit, it is implicit - whether or not the resulting string assumes ASCII compatibility or not depends on whether you pass a binary value (no assumption) or a string value (assumes ASCII compatibility).

How do you make that out? As far as I can see, Kristjan's
proposal will *always* call str() on the argument of a
%s format, regardless of its type. The *result*  of that
str() is then *required* (not assumed) to be encodable
as ascii. I don't see any type-dependent changes in
behaviour here.

Interpolating a bytes object as-is, without a conversion
to text, should be done by a different format specifier,
such as %b. All text/bytes conversions are then explicit:
if you write %s, then you're encoding something as ascii,
but if you write %b, you're just inserting something
that's already binary.

--
Greg
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to