[Python-Dev] PEP 460 reboot and a bitter fight

Nick Coghlan ncoghlan at gmail.com
Mon Jan 13 14:06:04 CET 2014


On 13 January 2014 17:59, Ethan Furman <ethan at stoneleaf.us> wrote:
> On 01/12/2014 11:15 PM, Guido van Rossum wrote:
>>
>>
>> (It's too late here to write more, but it looks like we are in for a
>> bitter fight. :-( )
>
>
> It's already been a bitter fight.
>
> The opponents of %-interpolation (Nick, Antoine, Turnbull, D'Aprano, et al*)
> all seem to be arguing basically what Nick said.
>
> The proponents (myself, you, Stufft, Eric Smith, et al*) are arguing that
> bytes already has an ASCII bias, already has ASCII string methods, that it
> isn't the same as the Py2 world because if you combine a bytes object with a
> str object outside of interpolation (such as b'hello' + 'world') it doesn't
> work, that only bytes would ever be returned, etc, etc.
>
> With the possible exception of the question I just asked Nick,  I don't
> think we're going to get any new information.

I figured out tonight that it's only positioning ASCII interpolation
as an *alternative* to adding binary interpolation that I have a
problem with. It isn't, because you lose the structural assurance that
you haven't inadvertently introduced an assumption of ASCII
compatibility when you didn't need to. However, interpolation support
is a convenient enough interface that I can see a version that *only*
supports ASCII compatible interpolation being an attractive nuisance
that becomes a source of hard to detect and fix data corruption bugs
(just like the str type in Python 2).

If we add both, my objections go away: people like me can use the
Python 3 only formatb and formatb_map methods and be confident we
haven't inadvertently introduced any assumptions regarding ASCII
compatibility, while folks that know they're dealing with an ASCII
compatible format can use the ASCII assuming versions that are
designed to be source compatible with Python 2.

If someone incorrectly uses format() or format_map() when they should
be using the pure binary versions, that's a trivial bug fix (adding
the necessary "b", and perhaps some explicit encoding calls) rather
than a major restructuring of the code.

If they use mod-formatting, that's a slightly bigger fix, but still
just switching to a different spelling of the formatting operation.

Both use cases (binary only and ASCII compatible) get covered cleanly,
and nobody has to lose out.

Cheers,
Nick.


-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list