]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-136914: Fix support of cached functions and properties in DocTest's lineno...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 7 Oct 2025 18:48:10 +0000 (20:48 +0200)
committerGitHub <noreply@github.com>
Tue, 7 Oct 2025 18:48:10 +0000 (20:48 +0200)
commit137c784fbfdd7efe4b8a9269c97c44f696a10757
tree6d7389a8505e4909c80461c198438ea205fbfb49
parentac147be05f127a304b04285570b945b45af5070a
[3.14] gh-136914: Fix support of cached functions and properties in DocTest's lineno computation (GH-136930) (#137616)

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().
(cherry picked from commit fece15d29f28e89f1231afa80508c80ed28dc37d)

Co-authored-by: Denis Laxalde <denis@laxalde.org>
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]