changeset: 98883:e80d1e9737d4 parent: 98879:8d3932671e48 parent: 98882:bbf00faf25ff user: Serhiy Storchaka date: Thu Oct 29 08:17:10 2015 +0200 files: Lib/inspect.py Lib/test/test_inspect.py Misc/ACKS Misc/NEWS description: Issue #25503: Fixed inspect.getdoc() for inherited docstrings of properties. Original patch by John Mark Vandenberg. diff -r 8d3932671e48 -r e80d1e9737d4 Lib/inspect.py --- a/Lib/inspect.py Wed Oct 28 21:45:01 2015 +0200 +++ b/Lib/inspect.py Thu Oct 29 08:17:10 2015 +0200 @@ -527,17 +527,18 @@ cls = self else: cls = self.__class__ + # Should be tested before isdatadescriptor(). + elif isinstance(obj, property): + 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 - elif isinstance(obj, property): - func = f.fget - name = func.__name__ - cls = _findclass(func) - if cls is None or getattr(cls, name) is not obj: - return None else: return None diff -r 8d3932671e48 -r e80d1e9737d4 Lib/test/inspect_fodder.py --- a/Lib/test/inspect_fodder.py Wed Oct 28 21:45:01 2015 +0200 +++ b/Lib/test/inspect_fodder.py Thu Oct 29 08:17:10 2015 +0200 @@ -45,14 +45,17 @@ 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 FesteringGob(MalodorousPervert, ParrotDroppings): def abuse(self, a, b, c): pass + + @property def contradiction(self): pass diff -r 8d3932671e48 -r e80d1e9737d4 Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py Wed Oct 28 21:45:01 2015 +0200 +++ b/Lib/test/test_inspect.py Thu Oct 29 08:17:10 2015 +0200 @@ -393,8 +393,8 @@ 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) diff -r 8d3932671e48 -r e80d1e9737d4 Misc/ACKS --- a/Misc/ACKS Wed Oct 28 21:45:01 2015 +0200 +++ b/Misc/ACKS Thu Oct 29 08:17:10 2015 +0200 @@ -1483,6 +1483,7 @@ Ville Vainio Andi Vajda Case Van Horsen +John Mark Vandenberg Kyle VanderBeek Andrew Vant Atul Varma diff -r 8d3932671e48 -r e80d1e9737d4 Misc/NEWS --- a/Misc/NEWS Wed Oct 28 21:45:01 2015 +0200 +++ b/Misc/NEWS Thu Oct 29 08:17:10 2015 +0200 @@ -63,6 +63,9 @@ 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.