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.

Author ngrover
Recipients
Date 2006-12-11.20:40:12
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
When using pydoc to query a package, a "PACKAGE CONTENTS" list is provided to show the modules and packages that are in that package. That list will be incomplete if we are querying a package that has been split across multiple directories.

Suppose you have the following:

/first/path/foo/__init__.py
/first/path/foo/one.py
/second/path/foo/__init__.py
/second/path/foo/two.py

and sys.path includes /first/path/ and /second/path/. If both of the foo/__init__.py files are empty, then "import foo" will only allow you to import modules from one of those two foo/ directories (whichever is found first in sys.path). However, if we add the following to both foo/__init__.py files, then we can import foo.one and foo.two because "foo" is considered to be a single package split across two directories:

from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)

Please see http://www.python.org/doc/2.4.2/lib/module-pkgutil.html for some related information.

On line 1052 of pydoc.py, we have the following:

for file in os.listdir(object.__path__[0]):

and in that loop we only read the contents of the FIRST directory in the package's __path__. That should be updated to read the contents of ALL directories in the package's __path__. The following change will do that:

% diff -w pydoc.py pydoc.py.orig
1052,1054c1052,1053
<             for objectDir in object.__path__:
<                 for file in os.listdir(objectDir):
<                     path = os.path.join(objectDir, file)
---
>             for file in os.listdir(object.__path__[0]):
>                 path = os.path.join(object.__path__[0], file)

I've attached that updated pydoc.py file to this submission. Please consider that as a replacement for the existing pydoc.py module that's currently being distributed.
History
Date User Action Args
2007-08-23 14:50:39adminlinkissue1613479 messages
2007-08-23 14:50:39admincreate