]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-99433: Fix `doctest` failure on `types.MethodWrapperType` (#99434)
authorNikita Sobolev <mail@sobolevn.me>
Fri, 30 Dec 2022 11:55:01 +0000 (14:55 +0300)
committerGitHub <noreply@github.com>
Fri, 30 Dec 2022 11:55:01 +0000 (17:25 +0530)
Lib/doctest.py
Lib/test/doctest_lineno.py
Misc/NEWS.d/next/Library/2022-11-13-15-32-19.gh-issue-99433.Ys6y0A.rst [new file with mode: 0644]

index b2ef2ce63672ebdc4ed83001f421bbc3711acbf5..dafad505ef0e86a11b289da0ae7a9b01ae966e84 100644 (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__'):
index be198513a1502ca97843ca6dc10fe9d58336cf59..729a68aceaa99013f527ce0e5dce3f183c6a5a95 100644 (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__
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 (file)
index 0000000..8e13a9a
--- /dev/null
@@ -0,0 +1 @@
+Fix :mod:`doctest` failure on :class:`types.MethodWrapperType` in modules.