Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c88a83e

Browse files
gh-99433: Fix doctest failure on types.MethodWrapperType (GH-99434)
(cherry picked from commit 79c10b7) Co-authored-by: Nikita Sobolev <[email protected]>
1 parent dd520e7 commit c88a83e

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

Lib/doctest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,8 @@ def _from_module(self, module, object):
956956
return module is inspect.getmodule(object)
957957
elif inspect.isfunction(object):
958958
return module.__dict__ is object.__globals__
959-
elif inspect.ismethoddescriptor(object):
959+
elif (inspect.ismethoddescriptor(object) or
960+
inspect.ismethodwrapper(object)):
960961
if hasattr(object, '__objclass__'):
961962
obj_mod = object.__objclass__.__module__
962963
elif hasattr(object, '__module__'):

Lib/test/doctest_lineno.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ def method_with_doctest(self):
4848
>>> MethodWrapper.method_with_doctest.__name__
4949
'method_with_doctest'
5050
"""
51+
52+
# https://github.com/python/cpython/issues/99433
53+
str_wrapper = object().__str__
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix :mod:`doctest` failure on :class:`types.MethodWrapperType` in modules.

0 commit comments

Comments
 (0)