[Python-Dev] Static analysis of CPython using coccinelle/spatch
Terry Reedy
tjreedy at udel.edu
Wed Nov 18 01:45:20 CET 2009
A.M. Kuchling wrote:
> On Mon, Nov 16, 2009 at 03:27:53PM -0500, David Malcolm wrote:
>> Has anyone else looked at using Coccinelle/spatch[1] on CPython source
>> code?
>
> For an excellent explanation of Coccinelle, see
> <http://lwn.net/Articles/315686/>.
For those who have not looked, Coccinelle means ladybug (a bug-eating
bug ;-) in French. Its principle use to to take C code and a SmPl file
of high-level patch descriptions (fixers, in 2to3 talk) and produce a
standard diff file. I wonder if this could be used to help people
migrate C extensions to 3.1, by developing a SmPl file with the needed
changes dictated by API changes. This is similar to its motivating
application to Linux. From
http://coccinelle.lip6.fr/
"Coccinelle is a program matching and transformation engine which
provides the language SmPL (Semantic Patch Language) for specifying
desired matches and transformations in C code. Coccinelle was initially
targeted towards performing collateral evolutions in Linux. Such
evolutions comprise the changes that are needed in client code in
response to evolutions in library APIs, and may include modifications
such as renaming a function, adding a function argument whose value is
somehow context-dependent, and reorganizing a data structure. "
As I understand it, the problem with C extensions and 3.1 is the current
lack of a "collateral evolution" tool like 2to3 for Python code.
Terry Jan Reedy
More information about the Python-Dev
mailing list