Getting the general case right seems a bit too difficult. Examples like
[execfile(n) for n in names if condition(n)]
execfile(execfile(n1) or n2)
try: 1 / 0
except execfile(n) or ZeroDivisionError: pass
would require rather complex transformations to get exactly matching behaviour, and obviously we don't want to explode the fixer code to support such nonsense.
I think it is enough to cover the case of an execfile() call that forms a statement of its own. Browsing through the first ten pages of a Google code search for "execfile" didn't reveal any other uses, except for a few that aren't covered by the current version of the fixer either. [1]
I'd suggest to simply throw a "could not convert" warning for any other uses of execfile(). Opinions?
[1]: http://www.google.com/codesearch#yqvQ9RM69FY/mercurial/lsprof.py&q=execfile&sq=&l=111&ct=rc&cd=49 |