Issue 1628895: Pydoc sets choices for doc locations incorrectly (original) (raw)

In pydoc.Helper.init I see this code:

    execdir = os.path.dirname(sys.executable)
    homedir = os.environ.get('PYTHONHOME')
    for dir in [os.environ.get('PYTHONDOCS'),
                homedir and os.path.join(homedir, 'doc'),
                os.path.join(execdir, 'doc'),
                '/usr/doc/python-docs-' + split(sys.version)[0],
                '/usr/doc/python-' + split(sys.version)[0],
                '/usr/doc/python-docs-' + sys.version[:3],
                '/usr/doc/python-' + sys.version[:3],
                os.path.join(sys.prefix, 'Resources/English.lproj/Documenta$            if dir and os.path.isdir(os.path.join(dir, 'lib')):
            self.docdir = dir

I think the third choice in the list of candidate directories is wrong. execdir is the directory of the Python executable (e.g., it's /usr/local/bin by default). I think it should be set as

execdir = os.path.dirname(os.path.dirname(sys.executable))

You're not going to find a "doc" directory in /usr/local/bin.