Add 2to3/fix_reload.py.

This commit is contained in:
Valentin Lorentz 2012-08-05 13:28:09 +02:00
parent 32a7da6f51
commit d4f5c03b3f
3 changed files with 30 additions and 2 deletions

27
2to3/fix_reload.py Normal file
View File

@ -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

View File

@ -2,11 +2,12 @@
import sys import sys
from lib2to3.main import main 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 # Hacks
sys.modules['lib2to3.fixes.fix_def_iteritems'] = fix_def_iteritems 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_itervalues'] = fix_def_itervalues
sys.modules['lib2to3.fixes.fix_def_iterkeys'] = fix_def_iterkeys sys.modules['lib2to3.fixes.fix_def_iterkeys'] = fix_def_iterkeys
sys.modules['lib2to3.fixes.fix_reload'] = fix_reload
sys.exit(main("lib2to3.fixes")) sys.exit(main("lib2to3.fixes"))

View File

@ -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 "$@"