[New-bugs-announce] [issue25757] Subclasses of property lose docstring

Torsten Landschoff report at bugs.python.org
Fri Nov 27 18:43:52 EST 2015


New submission from Torsten Landschoff:

I actually found this in Python2, but it is still unchanged in Python 3.6 dev. Namely, creating an instance of a class derived from property will drop the docstring passed explicitly to the constructor: 

torsten at defiant:~$ python3.6
Python 3.6.0a0 (default:9fcfdb53e8af, Nov 27 2015, 23:11:09) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> property(doc="Hello world").__doc__
'Hello world'
>>> class SubProp(property): pass
... 
>>> SubProp(doc="Hello world").__doc__
>>>

This war surprising to me. I actually used a subclass of property to describe fields of configuration classes with extensive documentation, which disappeared during runtime.

In Python2 I work around this by assigning to __doc__ as the last thing in the constructor of my SubProp class.

----------
components: Interpreter Core
messages: 255511
nosy: torsten
priority: normal
severity: normal
status: open
title: Subclasses of property lose docstring
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25757>
_______________________________________


More information about the New-bugs-announce mailing list