]> granicus.if.org Git - python/commitdiff
Patch #934356: if a module defines __all__, believe that rather than using
authorJohannes Gijsbers <jlg@dds.nl>
Mon, 30 Aug 2004 14:13:04 +0000 (14:13 +0000)
committerJohannes Gijsbers <jlg@dds.nl>
Mon, 30 Aug 2004 14:13:04 +0000 (14:13 +0000)
heuristics for filtering out imported names.

Lib/pydoc.py
Misc/NEWS

index 433bd281d7302662b056f33a18ec359531e4f3a0..daec8ab8191e152bab909c11a0154d2a3b179add 100755 (executable)
@@ -592,7 +592,9 @@ class HTMLDoc(Doc):
 
         classes, cdict = [], {}
         for key, value in inspect.getmembers(object, inspect.isclass):
-            if (inspect.getmodule(value) or object) is object:
+            # if __all__ exists, believe it.  Otherwise use old heuristic.
+            if (all is not None or
+                (inspect.getmodule(value) or object) is object):
                 if visiblename(key, all):
                     classes.append((key, value))
                     cdict[key] = cdict[value] = '#' + key
@@ -606,7 +608,9 @@ class HTMLDoc(Doc):
                             cdict[key] = cdict[base] = modname + '.html#' + key
         funcs, fdict = [], {}
         for key, value in inspect.getmembers(object, inspect.isroutine):
-            if inspect.isbuiltin(value) or inspect.getmodule(value) is object:
+            # if __all__ exists, believe it.  Otherwise use old heuristic.
+            if (all is not None or
+                inspect.isbuiltin(value) or inspect.getmodule(value) is object):
                 if visiblename(key, all):
                     funcs.append((key, value))
                     fdict[key] = '#-' + key
@@ -1015,12 +1019,16 @@ class TextDoc(Doc):
 
         classes = []
         for key, value in inspect.getmembers(object, inspect.isclass):
-            if (inspect.getmodule(value) or object) is object:
+            # if __all__ exists, believe it.  Otherwise use old heuristic.
+            if (all is not None
+                or (inspect.getmodule(value) or object) is object):
                 if visiblename(key, all):
                     classes.append((key, value))
         funcs = []
         for key, value in inspect.getmembers(object, inspect.isroutine):
-            if inspect.isbuiltin(value) or inspect.getmodule(value) is object:
+            # if __all__ exists, believe it.  Otherwise use old heuristic.
+            if (all is not None or
+                inspect.isbuiltin(value) or inspect.getmodule(value) is object):
                 if visiblename(key, all):
                     funcs.append((key, value))
         data = []
index 1cab3045d73420d557e3e535cc6368f470fe05ad..24780561eb19af8a2492cee2a7373086dafb1985 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -79,6 +79,9 @@ Extension modules
 Library
 -------
 
+- Patch #934356: if a module defines __all__, believe that rather than using
+  heuristics for filtering out imported names. 
+
 - Patch #941486: added os.path.lexists(), which returns True for broken
   symlinks, unlike os.path.exists().