Commit b539cef3 authored by Sanyam Khurana's avatar Sanyam Khurana Committed by Nick Coghlan

bpo-35614: Fix pydoc help() on metaclasses (#11357)

parent 1d300ce1
...@@ -1255,7 +1255,7 @@ location listed above. ...@@ -1255,7 +1255,7 @@ location listed above.
# List the built-in subclasses, if any: # List the built-in subclasses, if any:
subclasses = sorted( subclasses = sorted(
(str(cls.__name__) for cls in object.__subclasses__() (str(cls.__name__) for cls in type.__subclasses__(object)
if not cls.__name__.startswith("_") and cls.__module__ == "builtins"), if not cls.__name__.startswith("_") and cls.__module__ == "builtins"),
key=str.lower key=str.lower
) )
......
...@@ -636,6 +636,17 @@ class PydocDocTest(unittest.TestCase): ...@@ -636,6 +636,17 @@ class PydocDocTest(unittest.TestCase):
# Testing that the subclasses section does not appear # Testing that the subclasses section does not appear
self.assertNotIn('Built-in subclasses', text) self.assertNotIn('Built-in subclasses', text)
def test_builtin_on_metaclasses(self):
"""Tests help on metaclasses.
When running help() on a metaclasses such as type, it
should not contain any "Built-in subclasses" section.
"""
doc = pydoc.TextDoc()
text = doc.docclass(type)
# Testing that the subclasses section does not appear
self.assertNotIn('Built-in subclasses', text)
@unittest.skipIf(sys.flags.optimize >= 2, @unittest.skipIf(sys.flags.optimize >= 2,
'Docstrings are omitted with -O2 and above') 'Docstrings are omitted with -O2 and above')
@unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(),
......
Fixed help() on metaclasses. Patch by Sanyam Khurana.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment