]> granicus.if.org Git - python/commitdiff
Issue #25503: Fixed inspect.getdoc() for inherited docstrings of properties.
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 29 Oct 2015 06:15:50 +0000 (08:15 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 29 Oct 2015 06:15:50 +0000 (08:15 +0200)
Original patch by John Mark Vandenberg.

Lib/inspect.py
Lib/test/inspect_fodder.py
Lib/test/test_inspect.py
Misc/ACKS
Misc/NEWS

index bf4f87d5cfa6432bb1dff1bb07e5df478c843fdb..b65bec7adf677e0b7f0c4222f4f4ca7c1f851bb9 100644 (file)
@@ -527,17 +527,18 @@ def _finddoc(obj):
             cls = self
         else:
             cls = self.__class__
-    elif ismethoddescriptor(obj) or isdatadescriptor(obj):
-        name = obj.__name__
-        cls = obj.__objclass__
-        if getattr(cls, name) is not obj:
-            return None
+    # Should be tested before isdatadescriptor().
     elif isinstance(obj, property):
-        func = f.fget
+        func = obj.fget
         name = func.__name__
         cls = _findclass(func)
         if cls is None or getattr(cls, name) is not obj:
             return None
+    elif ismethoddescriptor(obj) or isdatadescriptor(obj):
+        name = obj.__name__
+        cls = obj.__objclass__
+        if getattr(cls, name) is not obj:
+            return None
     else:
         return None
 
index 068d8258b925d2c3b750d6e1e6971afd4c0f12cf..711badad849211f6b390fb68c8d7c3d9acd157a4 100644 (file)
@@ -45,14 +45,17 @@ class StupidGit:
             self.ex = sys.exc_info()
             self.tr = inspect.trace()
 
+    @property
     def contradiction(self):
         'The automatic gainsaying.'
         pass
 
-# line 48
+# line 53
 class MalodorousPervert(StupidGit):
     def abuse(self, a, b, c):
         pass
+
+    @property
     def contradiction(self):
         pass
 
@@ -64,6 +67,8 @@ class ParrotDroppings:
 class FesteringGob(MalodorousPervert, ParrotDroppings):
     def abuse(self, a, b, c):
         pass
+
+    @property
     def contradiction(self):
         pass
 
index 955b2adcb279cf511aa86382e59fb6fde3c4c227..69ddb514d61e58829fdd45c3e5c6c0319753469f 100644 (file)
@@ -393,8 +393,8 @@ class TestRetrievingSourceCode(GetSourceBase):
 
     def test_getsource(self):
         self.assertSourceEqual(git.abuse, 29, 39)
-        self.assertSourceEqual(mod.StupidGit, 21, 50)
-        self.assertSourceEqual(mod.lobbest, 70, 71)
+        self.assertSourceEqual(mod.StupidGit, 21, 51)
+        self.assertSourceEqual(mod.lobbest, 75, 76)
 
     def test_getsourcefile(self):
         self.assertEqual(normcase(inspect.getsourcefile(mod.spam)), modfile)
index f8fcccf61138b738f42065fa961ba5f51734652d..c7be8406c32638695eaa18329d4d404f06415839 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1480,6 +1480,7 @@ Lukas Vacek
 Ville Vainio
 Andi Vajda
 Case Van Horsen
+John Mark Vandenberg
 Kyle VanderBeek
 Andrew Vant
 Atul Varma
index 638964ec3617f36cee7588d2e68f492bc16ed508..be859edcdcc6237067763f308494f1e91b35d972 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -45,6 +45,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #25503: Fixed inspect.getdoc() for inherited docstrings of properties.
+  Original patch by John Mark Vandenberg.
+
 - Issue #21827: Fixed textwrap.dedent() for the case when largest common
   whitespace is a substring of smallest leading whitespace.
   Based on patch by Robert Li.