Skip to content

Commit

Permalink
gh-99433: Fix doctest failure on types.MethodWrapperType (GH-99434)
Browse files Browse the repository at this point in the history
(cherry picked from commit 79c10b7)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
  • Loading branch information
miss-islington and sobolevn authored Dec 30, 2022
1 parent dd520e7 commit c88a83e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Lib/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,8 @@ def _from_module(self, module, object):
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__'):
Expand Down
3 changes: 3 additions & 0 deletions Lib/test/doctest_lineno.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ def method_with_doctest(self):
>>> MethodWrapper.method_with_doctest.__name__
'method_with_doctest'
"""

# https://github.com/python/cpython/issues/99433
str_wrapper = object().__str__
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix :mod:`doctest` failure on :class:`types.MethodWrapperType` in modules.

0 comments on commit c88a83e

Please sign in to comment.