mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
gh-117692: Fix AttributeError in DocTestFinder on wrapped builtin_or_method (#117699)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
f90ff03672
commit
4bb7d121bc
3 changed files with 24 additions and 1 deletions
|
|
@ -1140,7 +1140,14 @@ 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 = inspect.unwrap(obj).__code__
|
||||
obj = inspect.unwrap(obj)
|
||||
try:
|
||||
obj = obj.__code__
|
||||
except AttributeError:
|
||||
# Functions implemented in C don't necessarily
|
||||
# have a __code__ attribute.
|
||||
# If there's no code, there's no lineno
|
||||
return None
|
||||
if inspect.istraceback(obj): obj = obj.tb_frame
|
||||
if inspect.isframe(obj): obj = obj.f_code
|
||||
if inspect.iscode(obj):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue