Bugs item #1613479, was opened at 2006-12-11 12:40
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1613479&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nishkar Grover (ngrover)
Assigned to: Nobody/Anonymous (nobody)
Summary: pydoc info for a package doesn't list all package contents

Initial Comment:
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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1613479&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to