gh-99433: Fix doctest failure on types.MethodWrapperType (#99434)

This commit is contained in:
Nikita Sobolev 2022-12-30 14:55:01 +03:00 committed by GitHub
parent 894f2c3c16
commit 79c10b7da8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View File

@ -956,7 +956,8 @@ class DocTestFinder:
return module is inspect.getmodule(object)
elif inspect.isfunction(object):
return module.__dict__ is object.__globals__
elif inspect.ismethoddescriptor(object):
elif (inspect.ismethoddescriptor(object) or
inspect.ismethodwrapper(object)):
if hasattr(object, '__objclass__'):
obj_mod = object.__objclass__.__module__
elif hasattr(object, '__module__'):

View File

@ -48,3 +48,6 @@ class MethodWrapper:
>>> MethodWrapper.method_with_doctest.__name__
'method_with_doctest'
"""
# https://github.com/python/cpython/issues/99433
str_wrapper = object().__str__

View File

@ -0,0 +1 @@
Fix :mod:`doctest` failure on :class:`types.MethodWrapperType` in modules.