mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-44904: Fix classmethod property bug in doctest module (GH-28838)
The doctest module raised an error if a docstring contained an example that
attempted to access a classmethod property. (Stacking '@classmethod' on top of
`@property` has been supported since Python 3.9; see
https://docs.python.org/3/howto/descriptor.htmlGH-class-methods.)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit b1302abcc8
)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
21150c6fa3
commit
8365a5b5ab
4 changed files with 21 additions and 4 deletions
|
@ -1022,10 +1022,8 @@ class DocTestFinder:
|
|||
if inspect.isclass(obj) and self._recurse:
|
||||
for valname, val in obj.__dict__.items():
|
||||
# Special handling for staticmethod/classmethod.
|
||||
if isinstance(val, staticmethod):
|
||||
val = getattr(obj, valname)
|
||||
if isinstance(val, classmethod):
|
||||
val = getattr(obj, valname).__func__
|
||||
if isinstance(val, (staticmethod, classmethod)):
|
||||
val = val.__func__
|
||||
|
||||
# Recurse to methods, properties, and nested classes.
|
||||
if ((inspect.isroutine(val) or inspect.isclass(val) or
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue