mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
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`.
This commit is contained in:
parent
13c4def692
commit
d4544cb232
2 changed files with 10 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue