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: 1 addition & 1 deletion Lib/pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def visiblename(name, all=None, obj=None):
if name.startswith('_') and hasattr(obj, '_fields'):
return True
# Ignore __future__ imports.
if name in _future_feature_names:
if obj is not __future__ and name in _future_feature_names:
if isinstance(getattr(obj, name, None), __future__._Feature):
return False
if all is not None:
Expand Down
17 changes: 17 additions & 0 deletions Lib/test/test_pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,23 @@ class B(A)
for expected_line in expected_lines:
self.assertIn(expected_line, as_text)

def test__future__imports(self):
# __future__ features are excluded from module help,
# except when it's the __future__ module itself
import __future__
future_text, _ = get_pydoc_text(__future__)
future_html, _ = get_pydoc_html(__future__)
pydoc_mod_text, _ = get_pydoc_text(pydoc_mod)
pydoc_mod_html, _ = get_pydoc_html(pydoc_mod)

for feature in __future__.all_feature_names:
txt = f"{feature} = _Feature"
html = f"<strong>{feature}</strong> = _Feature"
self.assertIn(txt, future_text)
self.assertIn(html, future_html)
self.assertNotIn(txt, pydoc_mod_text)
self.assertNotIn(html, pydoc_mod_html)


class PydocImportTest(PydocBaseTest):

Expand Down