gh-115392: Fix doctest reporting incorrect line numbers for decorated functions (#115440)

This commit is contained in:
Brian Schubert 2024-02-14 10:01:27 -05:00 committed by GitHub
parent 6755c4e0c8
commit bb791c7728
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 23 additions and 1 deletions

View file

@ -1140,7 +1140,7 @@ class DocTestFinder:
obj = obj.fget
if inspect.isfunction(obj) and getattr(obj, '__doc__', None):
# We don't use `docstring` var here, because `obj` can be changed.
obj = obj.__code__
obj = inspect.unwrap(obj).__code__
if inspect.istraceback(obj): obj = obj.tb_frame
if inspect.isframe(obj): obj = obj.f_code
if inspect.iscode(obj):