mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #25503: Fixed inspect.getdoc() for inherited docstrings of properties.
Original patch by John Mark Vandenberg.
This commit is contained in:
parent
f8152c67f5
commit
ac4bdcc80e
5 changed files with 19 additions and 9 deletions
|
@ -527,17 +527,18 @@ def _finddoc(obj):
|
||||||
cls = self
|
cls = self
|
||||||
else:
|
else:
|
||||||
cls = self.__class__
|
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):
|
elif ismethoddescriptor(obj) or isdatadescriptor(obj):
|
||||||
name = obj.__name__
|
name = obj.__name__
|
||||||
cls = obj.__objclass__
|
cls = obj.__objclass__
|
||||||
if getattr(cls, name) is not obj:
|
if getattr(cls, name) is not obj:
|
||||||
return None
|
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:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -45,14 +45,17 @@ class StupidGit:
|
||||||
self.ex = sys.exc_info()
|
self.ex = sys.exc_info()
|
||||||
self.tr = inspect.trace()
|
self.tr = inspect.trace()
|
||||||
|
|
||||||
|
@property
|
||||||
def contradiction(self):
|
def contradiction(self):
|
||||||
'The automatic gainsaying.'
|
'The automatic gainsaying.'
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# line 48
|
# line 53
|
||||||
class MalodorousPervert(StupidGit):
|
class MalodorousPervert(StupidGit):
|
||||||
def abuse(self, a, b, c):
|
def abuse(self, a, b, c):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
def contradiction(self):
|
def contradiction(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -64,6 +67,8 @@ class ParrotDroppings:
|
||||||
class FesteringGob(MalodorousPervert, ParrotDroppings):
|
class FesteringGob(MalodorousPervert, ParrotDroppings):
|
||||||
def abuse(self, a, b, c):
|
def abuse(self, a, b, c):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
def contradiction(self):
|
def contradiction(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -393,8 +393,8 @@ class TestRetrievingSourceCode(GetSourceBase):
|
||||||
|
|
||||||
def test_getsource(self):
|
def test_getsource(self):
|
||||||
self.assertSourceEqual(git.abuse, 29, 39)
|
self.assertSourceEqual(git.abuse, 29, 39)
|
||||||
self.assertSourceEqual(mod.StupidGit, 21, 50)
|
self.assertSourceEqual(mod.StupidGit, 21, 51)
|
||||||
self.assertSourceEqual(mod.lobbest, 70, 71)
|
self.assertSourceEqual(mod.lobbest, 75, 76)
|
||||||
|
|
||||||
def test_getsourcefile(self):
|
def test_getsourcefile(self):
|
||||||
self.assertEqual(normcase(inspect.getsourcefile(mod.spam)), modfile)
|
self.assertEqual(normcase(inspect.getsourcefile(mod.spam)), modfile)
|
||||||
|
|
|
@ -1480,6 +1480,7 @@ Lukas Vacek
|
||||||
Ville Vainio
|
Ville Vainio
|
||||||
Andi Vajda
|
Andi Vajda
|
||||||
Case Van Horsen
|
Case Van Horsen
|
||||||
|
John Mark Vandenberg
|
||||||
Kyle VanderBeek
|
Kyle VanderBeek
|
||||||
Andrew Vant
|
Andrew Vant
|
||||||
Atul Varma
|
Atul Varma
|
||||||
|
|
|
@ -45,6 +45,9 @@ Core and Builtins
|
||||||
Library
|
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
|
- Issue #21827: Fixed textwrap.dedent() for the case when largest common
|
||||||
whitespace is a substring of smallest leading whitespace.
|
whitespace is a substring of smallest leading whitespace.
|
||||||
Based on patch by Robert Li.
|
Based on patch by Robert Li.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue