[issue4423] 2to3 replaces "arbitrary" variables

Martin v. Löwis report at bugs.python.org
Tue Nov 25 05:03:02 CET 2008

Martin v. Löwis <martin at v.loewis.de> added the comment:

Are there any plans to improve that? In the specific case, it would help
if commands gets only replaced if an import of commands appears "in
scope" (or, if that is too difficult, anywhere in the file). I think
2to3 should create a list of all names that get imported anywhere, and
compare candidates for renaming against this list.

Also, I tried to work-around by just deleting "commands" from MAPPING
(nobody uses the commands module, anyway); this unfortunately failed
because PATTERN already had the name compiled in. It would be helpful if
PATTERN was computed more lazily, e.g. by overriding compile_pattern.
(I then worked around by regenerating PATTERN after monkey-patching

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list