Pretty good. I think you used fix_apply.py as an example? That unfortunately doesn't handle the following case: apply(f, x, y).something The has_key() fixes *does* support that (using the "after=*any" pattern. Can you copy the relevant parts from that fixer? Also, what do you think of how easy it is to write a refactoring using this tool?
Yes, I looked at fix_apply and didn't think about additional trailers. Attaching updated patch. I think once you get the general idea, it's fairly easy to write refactorings. (I was only stuck for a while figuring out that only one argument doesn't create an "arglist" node at all). File Added: 2to3-intern-2.diff
OK, check it in. We need to figure out one more thing eventually -- how to insert the needed "import sys" if it isn't there already. But let's put that off a bit.