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@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue25757>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to