Skip to content

[3.14] gh-136914: Fix support of cached functions and properties in DocTest's lineno computation (GH-136930) #137616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 3.14
Choose a base branch
from

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Aug 10, 2025

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 fece15d)

Co-authored-by: Denis Laxalde denis@laxalde.org

…cTest's lineno computation (pythonGH-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 fece15d)

Co-authored-by: Denis Laxalde <denis@laxalde.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants