[Python-checkins] cpython (3.5): Issue #25503: Fixed inspect.getdoc() for inherited docstrings of properties.
serhiy.storchaka
python-checkins at python.org
Thu Oct 29 02:20:43 EDT 2015
https://hg.python.org/cpython/rev/bbf00faf25ff
changeset: 98882:bbf00faf25ff
branch: 3.5
parent: 98878:3f29be82c944
user: Serhiy Storchaka <storchaka at gmail.com>
date: Thu Oct 29 08:15:50 2015 +0200
summary:
Issue #25503: Fixed inspect.getdoc() for inherited docstrings of properties.
Original patch by John Mark Vandenberg.
files:
Lib/inspect.py | 13 +++++++------
Lib/test/inspect_fodder.py | 7 ++++++-
Lib/test/test_inspect.py | 4 ++--
Misc/ACKS | 1 +
Misc/NEWS | 3 +++
5 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/Lib/inspect.py b/Lib/inspect.py
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -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 --git a/Lib/test/inspect_fodder.py b/Lib/test/inspect_fodder.py
--- a/Lib/test/inspect_fodder.py
+++ b/Lib/test/inspect_fodder.py
@@ -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 --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -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 --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1480,6 +1480,7 @@
Ville Vainio
Andi Vajda
Case Van Horsen
+John Mark Vandenberg
Kyle VanderBeek
Andrew Vant
Atul Varma
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -45,6 +45,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.
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list