summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorT. Wouters <thomas@python.org>2025-01-17 22:43:17 (GMT)
committerGitHub <noreply@github.com>2025-01-17 22:43:17 (GMT)
commitd4544cb232dee5f836a64b9126fbbefcbb6099de (patch)
tree28f8845a69e6c3fca656674d98b17616cd29715e /Lib/pydoc.py
parent13c4def692228f09df0b30c5f93bc515e89fc77f (diff)
downloadcpython-d4544cb232dee5f836a64b9126fbbefcbb6099de.zip
cpython-d4544cb232dee5f836a64b9126fbbefcbb6099de.tar.gz
cpython-d4544cb232dee5f836a64b9126fbbefcbb6099de.tar.bz2
gh-128923: fix test_pydoc for object subclasses without `__module__` (#128951)
Fix pydoc's docclass() for classes inheriting from object without the `__module__` attribute, like `_testcapi.HeapType`.
Diffstat (limited to 'Lib/pydoc.py')
-rw-r--r--Lib/pydoc.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 9e84292..922946e 100644
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1435,7 +1435,8 @@ location listed above.
# List the built-in subclasses, if any:
subclasses = sorted(
(str(cls.__name__) for cls in type.__subclasses__(object)
- if not cls.__name__.startswith("_") and cls.__module__ == "builtins"),
+ if (not cls.__name__.startswith("_") and
+ getattr(cls, '__module__', '') == "builtins")),
key=str.lower
)
no_of_subclasses = len(subclasses)