diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-10-28 08:09:41 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-28 08:09:41 (GMT) |
| commit | 1f45cc0dfa9a8febfc256411c803b4536719db97 (patch) | |
| tree | 2049fe508942ef5439b1d5f0afd4e4f05c63c0be /Lib/doctest.py | |
| parent | ce7a6afb797d2ffde45e9e902516b8437c8f9e31 (diff) | |
| download | cpython-1f45cc0dfa9a8febfc256411c803b4536719db97.zip cpython-1f45cc0dfa9a8febfc256411c803b4536719db97.tar.gz cpython-1f45cc0dfa9a8febfc256411c803b4536719db97.tar.bz2 | |
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 b1302abcc8a4be5f39b4d60a1ce28032b77655b3)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Diffstat (limited to 'Lib/doctest.py')
| -rw-r--r-- | Lib/doctest.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py index ba898f6..b27cbdf 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -1034,10 +1034,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 |
