]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-136914: Fix support of cached functions and properties in DocTest's lineno computa...
authorDenis Laxalde <denis@laxalde.org>
Fri, 25 Jul 2025 09:46:12 +0000 (11:46 +0200)
committerGitHub <noreply@github.com>
Fri, 25 Jul 2025 09:46:12 +0000 (12:46 +0300)
commitfece15d29f28e89f1231afa80508c80ed28dc37d
tree0dcee40c82713496b790f1b501e3859a9422e8b4
parentd5e75c07682864e9d265e11f5e4730147e7d4842
gh-136914: Fix support of cached functions and properties in DocTest's lineno computation (GH-136930)

Previously, DocTest's lineno of functions and methods decorated with
functools.cache(), functools.lru_cache() and functools.cached_property()
was not properly returned (None was returned) because the
computation relied on inspect.isfunction() which does not consider the
decorated result as a function.

We now use the more generic inspect.isroutine(), as elsewhere
in doctest's logic.

Also, added a special case for functools.cached_property().
Lib/doctest.py
Lib/test/test_doctest/doctest_lineno.py
Lib/test/test_doctest/test_doctest.py
Misc/NEWS.d/next/Library/2025-07-21-15-40-00.gh-issue-136914.-GNG-d.rst [new file with mode: 0644]