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 would be an explicit encoding operator with a known, fixed, and well 
specified encoder.
This would cover most of the use cases seen in this threadnought.  Others could 
be handled with explicit str formatting and encoding.

Imho, this is not equivalent to re-introducing automatic type conversion 
between binary/unicode, it is adding a specific convenience function for 
explicitly asking for ASCII encoding.

K
________________________________________
From: Python-Dev [python-dev-bounces+kristjan=ccpgames....@python.org] on 
behalf of Georg Brandl [g.bra...@gmx.net]
Sent: Sunday, January 12, 2014 09:23
To: python-dev@python.org
Subject: Re: [Python-Dev] PEP 460: allowing %d and %f and mojibake

Am 12.01.2014 09:57, schrieb Paul Moore:
> On 12 January 2014 01:01, Victor Stinner <victor.stin...@gmail.com> wrote:
>> Supporting formating integers would allow to write b"Content-Length:
>> %s\r\n" % 123, which would work on Python 2 and Python 3.
>
> I'm surprised that no-one is mentioning b"Content-Length: %s\r\n" %
> str(123) which works on Python 2 and 3, is explicit, and needs no
> special-casing of int in the format code.

Certainly doesn't work on Python 3 right now, and never should :)

Georg
_______________________________________________
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