[Python-Dev] PEP 460: allowing %d and %f and mojibake
Kristján Valur Jónsson
kristjan at ccpgames.com
Sun Jan 12 15:50:52 CET 2014
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.
From: Python-Dev [python-dev-bounces+kristjan=ccpgames.com at python.org] on behalf of Georg Brandl [g.brandl at gmx.net]
Sent: Sunday, January 12, 2014 09:23
To: python-dev at 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.stinner at 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 :)
More information about the Python-Dev