-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the property doctstring writeable #68252
Comments
I can't see any reason for property docstrings to be readonly: >>> p = property(doc='basic')
>>> p.__doc__
'basic'
>>> p.__doc__ = 'extended'
Traceback (most recent call last):
File "<pyshell#46>", line 1, in <module>
p.__doc__ = 'extended'
AttributeError: readonly attribute Among other things, making it writeable would simplify the ability to update the docstrings produced by namedtuple; Time.mtime.__doc__ = 'modification time'
Score.max = 'all time cumulative high score for a single season' |
Here is a patch. I'm not familiar with this part of the CPython source. So please tell me if there is a better way to do it. I only updated Doc/whatsnew/3.5, but other places in the documentation needs to be updated. |
If make docstrings writable, it would be good to ensure that they exactly are strings. And if make the property doctstring writable, may be make other docstrings writable? It may be useful for setting the same docstring for Python implementation and C accelerator. |
I don't see a need for this restriction. Even regular classes don't enforce this. |
Perhaps the property class now need set the tp_clear slot? |
New changeset 1e8a768fa0a5 by Raymond Hettinger in branch 'default': |
New changeset bde652ae05fd by Berker Peksag in branch 'default': |
LGTM. |
An example of uncollectable loop if tp_clear is not implemented: class A:
@property
def f(self): pass
A.f.__doc__ = (A.f,) |
New changeset 2ddadd0e736d by Raymond Hettinger in branch 'default': |
New changeset 5262dd507ee5 by Raymond Hettinger in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: