[Python-Dev] breaking list.append()

Tim Peters tim_one@email.msn.com
Wed, 1 Mar 2000 05:06:58 -0500

> ...
> so as far as I'm concerned, this was officially deprecated
> with Guido's post.  afaik, no official python documentation
> has explicitly mentioned this (and the fact that it doesn't
> explicitly allow it doesn't really matter, since the docs don't
> explicitly allow the x[a, b, c] syntax either.  both work in
> 1.5.2).

The "Subscriptions" section of the Reference Manual explicitly allows for

    dict[a, b, c]

and explicitly does not allow for

    sequence[a, b, c]

The "Mapping Types" section of the Library Ref does not explicitly allow for
it, though, and if you read it as implicitly allowing for it (based on the
Reference Manual's clarification of "key" syntax), you would also have to
read the Library Ref as allowing for

    dict.has_key(a, b, c)

Which 1.5.2 does allow, but which Guido very recently patched to treat as a
syntax error.

> ...
> sigh.  running checkappend over a 50k LOC application, I
> just realized that it doesn't catch a very common append
> pydiom.

[And, later, after prodding by GregS]

> this rather common pydiom:
>    append = list.append
>    for x in something:
>        append(...)

This limitation was pointed out in checkappend's module docstring.  Doesn't
make it any easier for you to swallow, but I needed to point out that you
didn't *have* to stumble into this the hard way <wink>.

> how fun.  even though 99% of all append calls are "legal",
> this "minor" change will break every single application and
> library we have :-(
> oh, wait.  xmlrpclib isn't affected.  always something!

What would you like to do, then?  The code will be at least as broken a year
from now, and probably more so -- unless you fix it.  So this sounds like an
indirect argument for never changing Python's behavior here.  Frankly, I
expect you could fix the 50K LOC in less time than it took me to write this
naggy response <0.50K wink>.

embrace-change-ly y'rs  - tim