This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author erik.bray
Recipients erik.bray
Date 2015-07-31.17:02:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1438362123.61.0.0930515598899.issue24766@psf.upfronthosting.co.za>
In-reply-to
Content
This issue is directly related to http://bugs.python.org/issue5890, the solution to which I think was incomplete.

The examples below use a trivial subclass of property (but apply as well to a less trivial one):

>>> class myproperty(property): pass
...

When using myproperty with the decorator syntax, or simply without specifying a doc= argument, the docstring is properly inherited from the getter, as was fixed by issue5890:

>>> class A:
...     @myproperty
...     def foo(self):
...         """The foo."""
...         return 1
... 
>>> A.foo.__doc__
'The foo.'

However, when using the doc= argument, this behavior is broken:

>>> class B:
...     def _get_foo(self): return 1
...     foo = myproperty(_get_foo, doc="The foo.")
... 
>>> B.foo.__doc__
>>> B.foo.__doc__ is None
True


The attached patch resolves the issue by applying the special case for subclasses more generally.  If this looks good I'll add a test as well.

One thing I went back and forth on in the "if (Py_TYPE(self) != &PyProperty_Type)" block was whether or not to then deref prop->prop_doc and set it to NULL, since I don't think it's needed anymore at this point.  But I decided it was ultimately harmless to leave it.
History
Date User Action Args
2015-07-31 17:02:03erik.braysetrecipients: + erik.bray
2015-07-31 17:02:03erik.braysetmessageid: <1438362123.61.0.0930515598899.issue24766@psf.upfronthosting.co.za>
2015-07-31 17:02:03erik.braylinkissue24766 messages
2015-07-31 17:02:03erik.braycreate