This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: "2to3 -l" doesn't work when installed in /opt
Type: Stage:
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.0
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: collinwinter Nosy List: benjamin.peterson, collinwinter, vstinner
Priority: normal Keywords: patch

Created on 2008-08-14 15:44 by vstinner, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
2to3_fixer_dir.patch vstinner, 2008-08-14 15:54 Patch proposition to get the absolute directory
Messages (2)
msg71132 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-08-14 15:44
I just installed Python 3.0b2 in /opt/py3k and tried 2to3 tool:

$ /opt/py3k/bin/2to3 -l
Available transformations for the -f/--fix option:
Traceback (most recent call last):
  File "/opt/py3k/bin/2to3", line 5, in <module>
    sys.exit(refactor.main("lib2to3/fixes"))
  File "/opt/py3k/lib/python3.0/lib2to3/refactor.py", line 69, in main
    for fixname in get_all_fix_names(fixer_dir):
  File "/opt/py3k/lib/python3.0/lib2to3/refactor.py", line 102, in 
get_all_fix_names
    names = os.listdir(fixer_dir)
OSError: [Errno 2] No such file or directory: 'lib2to3/fixes'

fixer_dir is the relative directory name "lib2to3/fixes", it should be 
an absolute directory. Example (ugly code copied from 
RefactoringTool.get_fixers()) to get the full path in refactor.py 
(main function):

    if not os.path.isabs(fixer_dir):
        fixer_pkg = fixer_dir.replace(os.path.sep, ".")
        if os.path.altsep:
            fixer_pkg = fixer_pkg.replace(os.path.altsep, ".")
        mod = __import__(fixer_pkg, {}, {}, ["*"])
        fixer_dir = os.path.dirname(mod.__file__)
msg71170 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-08-15 12:58
This is a duplicate of #3131.
History
Date User Action Args
2022-04-11 14:56:37adminsetgithub: 47803
2008-08-15 12:58:44benjamin.petersonsetstatus: open -> closed
nosy: + benjamin.peterson
resolution: duplicate
messages: + msg71170
2008-08-14 15:54:50vstinnersetfiles: + 2to3_fixer_dir.patch
keywords: + patch
2008-08-14 15:44:55vstinnercreate