From d4f5c03b3f1f99643c5fd11da881727ec34aa07d Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 5 Aug 2012 13:28:09 +0200 Subject: [PATCH] Add 2to3/fix_reload.py. --- 2to3/fix_reload.py | 27 +++++++++++++++++++++++++++ 2to3/run.py | 3 ++- sandbox/run_2to3.sh | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 2to3/fix_reload.py diff --git a/2to3/fix_reload.py b/2to3/fix_reload.py new file mode 100644 index 000000000..7d2f4cb1e --- /dev/null +++ b/2to3/fix_reload.py @@ -0,0 +1,27 @@ +# Based on fix_intern.py. Original copyright: +# Copyright 2006 Georg Brandl. +# Licensed to PSF under a Contributor Agreement. + +"""Fixer for intern(). + +intern(s) -> sys.intern(s)""" + +# Local imports +from lib2to3 import pytree +from lib2to3 import fixer_base +from lib2to3.fixer_util import Name, Attr, touch_import + + +class FixReload(fixer_base.BaseFix): + BM_compatible = True + order = "pre" + + PATTERN = """ + power< 'reload' + after=any* + > + """ + + def transform(self, node, results): + touch_import(u'imp', u'reload', node) + return node diff --git a/2to3/run.py b/2to3/run.py index e8f823a67..4457f5603 100644 --- a/2to3/run.py +++ b/2to3/run.py @@ -2,11 +2,12 @@ import sys from lib2to3.main import main -import fix_def_iteritems, fix_def_itervalues, fix_def_iterkeys +import fix_def_iteritems, fix_def_itervalues, fix_def_iterkeys, fix_reload # Hacks sys.modules['lib2to3.fixes.fix_def_iteritems'] = fix_def_iteritems sys.modules['lib2to3.fixes.fix_def_itervalues'] = fix_def_itervalues sys.modules['lib2to3.fixes.fix_def_iterkeys'] = fix_def_iterkeys +sys.modules['lib2to3.fixes.fix_reload'] = fix_reload sys.exit(main("lib2to3.fixes")) diff --git a/sandbox/run_2to3.sh b/sandbox/run_2to3.sh index 2349f3f75..62385bac2 100755 --- a/sandbox/run_2to3.sh +++ b/sandbox/run_2to3.sh @@ -1 +1 @@ -python 2to3/run.py src/ plugins/ test/ scripts/* setup.py -wn -f all -f def_iteritems -f def_itervalues -f def_iterkeys "$@" +python 2to3/run.py src/ plugins/ test/ scripts/* setup.py -wn -f all -f def_iteritems -f def_itervalues -f def_iterkeys -f reload "$@"