Martijn Pieters <mj@digicool.com>
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.
<Guido's message snipped>
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.
The other thing to look out for is the "extra layer of indirection", where append is invoked through another name. For example::
foobar = [] push = foobar.append push( 'foo', 'bar' ) foobar [('foo', 'bar')]
This gets especially ugly if the bound method is passed as a "normal" function pointer into some completely different scope, which might invoke it with arbitrary parameters. Tres. -- ========================================================= Tres Seaver tseaver@palladion.com 713-523-6582 Palladion Software http://www.palladion.com