summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2022-12-30 11:55:01 (GMT)
committerGitHub <noreply@github.com>2022-12-30 11:55:01 (GMT)
commit79c10b7da84f52999dc483fc62c8e758ad3eff23 (patch)
treebf90cf0734f2ae70750bb49ed17e975314a4be5c
parent894f2c3c161933bd820ad322b3b678d89bc2377c (diff)
downloadcpython-79c10b7da84f52999dc483fc62c8e758ad3eff23.zip
cpython-79c10b7da84f52999dc483fc62c8e758ad3eff23.tar.gz
cpython-79c10b7da84f52999dc483fc62c8e758ad3eff23.tar.bz2
gh-99433: Fix `doctest` failure on `types.MethodWrapperType` (#99434)
-rw-r--r--Lib/doctest.py3
-rw-r--r--Lib/test/doctest_lineno.py3
-rw-r--r--Misc/NEWS.d/next/Library/2022-11-13-15-32-19.gh-issue-99433.Ys6y0A.rst1
3 files changed, 6 insertions, 1 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py
index b2ef2ce..dafad50 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -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__'):
diff --git a/Lib/test/doctest_lineno.py b/Lib/test/doctest_lineno.py
index be19851..729a68a 100644
--- a/Lib/test/doctest_lineno.py
+++ b/Lib/test/doctest_lineno.py
@@ -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__
diff --git a/Misc/NEWS.d/next/Library/2022-11-13-15-32-19.gh-issue-99433.Ys6y0A.rst b/Misc/NEWS.d/next/Library/2022-11-13-15-32-19.gh-issue-99433.Ys6y0A.rst
new file mode 100644
index 0000000..8e13a9a
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-11-13-15-32-19.gh-issue-99433.Ys6y0A.rst
@@ -0,0 +1 @@
+Fix :mod:`doctest` failure on :class:`types.MethodWrapperType` in modules.