From: "Patrick Phalen" <zope@teleo.net>
Fredrik Lundh has mentioned that this breaks Zope (and Medusa).
If so, it's probably not too soon to begin looking into it. 1.6 is due this summer.
---------- ## Forwarded Message ## ---------- Subject: Multi-argument append() is illegal Date: Mon, 28 Feb 2000 10:41:02 -0500 From: Guido van Rossum <guido@python.org>
I've noticed that there is some code out there that creates a list of tuples and uses code like list.append(a,b,c) to add the tuple (a,b,c) to the list. According to the documentation, this is illegal: append() only takes a single argument, and one should write list.append((a,b,c)). However, the actual append() implementation didn't mind, and implemented list.append(a,b,c) as list.append((a,b,c)). Many people are using this even though it's never been documented.
I am going to rectify this in Python 1.6 -- people coming from other languages might well expect list.append(a, b, c) to mean the same as list.append(a); list.append(b); list.append(c), and it's always been my philosophy to make ambiguous syntax illegal rather than to pick one interpretation randomly.
This message is simply a heads-up that you should be aware of this change (when 1.6 comes out, which should be before the summer). You can test your programs using the current CVS version (see www.python.org/download/cvs.html). You can also grep through your sources for a pattern like "\. *append *\(.*," -- which doesn't find every occurrence, but is a good starting point. If you have a smarter grep-like tool you may be able to write a tighter matching expression.
Watch out for false hits though: some classes define their own multi-argument append()...
--Guido van Rossum (home page: http://www.python.org/~guido/)
Using a more advanced pattern (one that weeds out most proper appends, and takes multiple lines into account), plus some hand weeding, brings up the following list of 'illegal' tuple appends: lib\python\ExportImportXML.py(109): self._tindex.append(self._oid, here) lib\python\Shared\DC\ZRDB\RDB.py(199): parsers.append(i,parser) lib\python\Shared\DC\xml\ppml.py(278): def __setitem__(self, k, v): self._d.append(k,v) lib\python\ZODB\FileStorage.py(633): self._tappend(oid, here) lib\python\ZPublisher\cgi.py(603): r.append(name, value) utilities\FS.py(145): self._tappend(oid, here) ZServer\HTTPServer.py(285): request.channel.queue.append(self.module_name, zrequest, zresponse) ZServer\medusa\asyncore.py(84): l.append (fd, flags) Above 8 occurences are all cases of tuples being appended to a list, using the 'illegal' style syntax. Note that I still may have missed occurences, and that Python 1.6 might break other things. The change from 1.5.1 to 1.5.2 broke certain things in Zope as well, usually because of library changes. For those of you that grok POSIX regexp, here is what I used to search these out: append[[:blank:]]*\(([^[{(,]|[[:space:]])+, where [:blank:] stands for whitespace (not including newlines), and [:space:] is whitespace (including newline). This will miss aliasing of .append (app=list.append), which I hunted out with a separate regexp, and lines like: append(1 # number 1 ,2 # number 2 which were again hunted (and none found) with another simple regexp. So I am fairly sure I got em all =). I have posted these to the Collector. Martijn Pieters | Software Engineer mailto:mj@digicool.com | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ | The Open Source Web Application Server ---------------------------------------------