Message102735
I found a workaround by excluding the "import" fixer that seems to work.
For the example,
> 2to3 -x import abs_imp_test
The command still modifies main, but it only removes the __future__ directive and doesn't modify the imports.
For my real-world package, which is using distutils, I added the following to get a build_py that will run 2to3:
try:
from distutils.command.build_py import build_py_2to3 as build_py
# exclude some fixers that break already compatible code
from lib2to3.refactor import get_fixers_from_package
fixers = get_fixers_from_package('lib2to3.fixes')
for skip_fixer in ['import']:
fixers.remove('lib2to3.fixes.fix_' + skip_fixer)
build_py.fixer_names = fixers
except ImportError:
from distutils.command.build_py import build_py
This works because the entire package is already using absolute imports wherever they are relevant, so removing the import fixer is appropriate. |
|
Date |
User |
Action |
Args |
2010-04-09 17:42:11 | jaraco | set | recipients:
+ jaraco |
2010-04-09 17:42:11 | jaraco | set | messageid: <1270834931.54.0.150904331286.issue8358@psf.upfronthosting.co.za> |
2010-04-09 17:42:10 | jaraco | link | issue8358 messages |
2010-04-09 17:42:09 | jaraco | create | |
|