diff options
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r-- | Lib/doctest.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py index fc0da59..4e362cb 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -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): |