Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ def docmodule(self, object, name=None, mod=None, *ignored):
for key, value in inspect.getmembers(object, inspect.isroutine):
# if __all__ exists, believe it. Otherwise use a heuristic.
if (all is not None
or inspect.isbuiltin(value)
or (inspect.getmodule(value) or object) is object):
if visiblename(key, all, object):
funcs.append((key, value))
Expand Down Expand Up @@ -1328,6 +1329,7 @@ def docmodule(self, object, name=None, mod=None, *ignored):
for key, value in inspect.getmembers(object, inspect.isroutine):
# if __all__ exists, believe it. Otherwise use a heuristic.
if (all is not None
or inspect.isbuiltin(value)
or (inspect.getmodule(value) or object) is object):
if visiblename(key, all, object):
funcs.append((key, value))
Expand Down
3 changes: 3 additions & 0 deletions Lib/test/test_pydoc/pydocfodder.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def B_classmethod(cls, x):
object_repr = object.__repr__
get = {}.get # same name
dict_get = {}.get
from math import sin


B.B_classmethod_ref = B.B_classmethod

Expand Down Expand Up @@ -186,3 +188,4 @@ def __call__(self, inst):
object_repr = object.__repr__
get = {}.get # same name
dict_get = {}.get
from math import sin # noqa: F401
13 changes: 13 additions & 0 deletions Lib/test/test_pydoc/test_pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1951,9 +1951,11 @@ def test_text_doc_routines_in_class(self, cls=pydocfodder.B):
if not support.MISSING_C_DOCSTRINGS:
self.assertIn(' | get(key, default=None, /) method of builtins.dict instance', lines)
self.assertIn(' | dict_get = get(key, default=None, /) method of builtins.dict instance', lines)
self.assertIn(' | sin(x, /)', lines)
else:
self.assertIn(' | get(...) method of builtins.dict instance', lines)
self.assertIn(' | dict_get = get(...) method of builtins.dict instance', lines)
self.assertIn(' | sin(...)', lines)

lines = self.getsection(result, f' | Class methods {where}:', ' | ' + '-'*70)
self.assertIn(' | B_classmethod(x)', lines)
Expand Down Expand Up @@ -2039,6 +2041,11 @@ def test_text_doc_routines_in_module(self):
self.assertIn(' __repr__(...) unbound builtins.object method', lines)
self.assertIn(' object_repr = __repr__(...) unbound builtins.object method', lines)

# builtin functions
if not support.MISSING_C_DOCSTRINGS:
self.assertIn(' sin(x, /)', lines)
else:
self.assertIn(' sin(...)', lines)

def test_html_doc_routines_in_module(self):
doc = pydoc.HTMLDoc()
Expand Down Expand Up @@ -2079,6 +2086,12 @@ def test_html_doc_routines_in_module(self):
self.assertIn(' __repr__(...) unbound builtins.object method', lines)
self.assertIn(' object_repr = __repr__(...) unbound builtins.object method', lines)

# builtin functions
if not support.MISSING_C_DOCSTRINGS:
self.assertIn(' sin(x, /)', lines)
else:
self.assertIn(' sin(...)', lines)


@unittest.skipIf(
is_wasm32,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix a bug in the :mod:`pydoc` module that was hiding functions in a Python
module if they were implemented in an extension module and the module did
not have ``__all__``.
Loading