New submission from John Mark Vandenberg:

inspect.getdoc's helper _finddoc raises an AttributeError on encountering a 
property, which is silently discarded.

>>> class Foo(object):
...     @property
...     def foo(self):
...         """foobar."""
...         return 'foo'
... 
>>> class Bar(Foo):
...     @property
...     def foo(self):
...         return 'bar'
... 
>>> import inspect
>>> inspect.getdoc(Foo.foo)
'foobar.'
>>> inspect.getdoc(Bar.foo)
>>>

How I came upon this was doing static code analysis, and the f.fget on line 522 
here looks very wrong.

http://bugs.python.org/review/15582/diff/14140/Lib/inspect.py

This code dedicated to supporting `property` does not work because of that, but 
also because a property is also a data descriptor so the 'property' branch is 
never executed.

>>> inspect.isdatadescriptor(property())
True

----------
components: Library (Lib)
files: getdoc-property.diff
keywords: patch
messages: 253653
nosy: John.Mark.Vandenberg
priority: normal
severity: normal
status: open
title: inspect.getdoc does find inherited property __doc__
type: behavior
versions: Python 3.5, Python 3.6
Added file: http://bugs.python.org/file40885/getdoc-property.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25503>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to