diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-03-03 12:20:00 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-03-03 15:41:22 -0700 |
commit | 9207b4c109158e96887d4262e3f9cbe2ab0fdf78 (patch) | |
tree | a249e535dbc23fc64cad2191dda4e0e73e7e39d2 | |
parent | e24e0d8d41cf2b64bc4e34ee71618c10c9043e5f (diff) | |
download | numpy-9207b4c109158e96887d4262e3f9cbe2ab0fdf78.tar.gz |
ENH: Skip already applied fixers when running 2to3.
This is done in `tools/py3tool.py` by providing a list of fixers that
is passed in the call to 2to3 with with the `-x` option that tells
2to3 to skip them.
Closes #3113
-rwxr-xr-x | tools/py3tool.py | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/tools/py3tool.py b/tools/py3tool.py index 53c4865e1..76ca2f026 100755 --- a/tools/py3tool.py +++ b/tools/py3tool.py @@ -55,6 +55,36 @@ EXTRA_2TO3_FLAGS = { 'numpy/oldnumeric/ma.py': '-x reduce', } +# Names of fixers to skip when running 2to3 +FIXES_TO_SKIP = [ + 'tuple_params', + 'throw', + 'sys_exc', + 'standarderror', + 'reduce', + 'raise', + 'paren', + 'operator', + 'ne', + 'methodattrs', + 'metaclass', + 'intern', + 'has_key', + 'getcwdu', + 'filter', + 'exitfunc', + 'execfile', + 'exec', + 'callable', + 'apply' +] + +skip_fixes= [] +for _t in FIXES_TO_SKIP: + skip_fixes.append('-x') + skip_fixes.append(_t) + + def main(): p = OptionParser(usage=__doc__.strip()) p.add_option("--clean", "-c", action="store_true", @@ -270,7 +300,12 @@ def sync_2to3(src, dst, patchfile=None, clean=False): _old_stdout = sys.stdout try: sys.stdout = StringIO() - lib2to3.main.main("lib2to3.fixes", ['-w', '-n'] + flags.split()+filenames) + opt = [] + opt.extend(['-w', '-n']) + opt.extend(skip_fixes) + opt.extend(flags.split()) + opt.extend(filenames) + lib2to3.main.main("lib2to3.fixes", opt) finally: sys.stdout = _old_stdout |