E674 bpo-41287: Handle `doc` argument of `property.__init__` in subclasses by sizmailov · Pull Request #23205 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-41287: Handle doc argument of property.__init__ in subclasses #23205

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

Merged
merged 19 commits into from
May 29, 2022
Merged
Changes from 1 commit
Commits
10000
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename local get_doc -> prop_doc
  • Loading branch information
sizmailov committed Apr 5, 2022
commit dcab455a9055238174fd972933b3e977678a148d
14 changes: 7 additions & 7 deletions Objects/descrobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1789,33 +1789,33 @@ property_init_impl(propertyobject *self, PyObject *fget, PyObject *fset,
Py_XSETREF(self->prop_name, NULL);

self->getter_doc = 0;
PyObject *get_doc = NULL;
PyObject *prop_doc = NULL;

/* if no docstring given and the getter has one, use that one */
if ((doc == NULL || doc == Py_None) && fget != NULL) {
int rc = _PyObject_LookupAttr(fget, &_Py_ID(__doc__), &get_doc);
int rc = _PyObject_LookupAttr(fget, &_Py_ID(__doc__), &prop_doc);
if (rc <= 0) {
return rc;
}
self->getter_doc = 1;
}
else {
get_doc = doc;
Py_XINCREF(get_doc);
prop_doc = doc;
Py_XINCREF(prop_doc);
}


if (Py_IS_TYPE(self, &PyProperty_Type)) {
Py_XSETREF(self->prop_doc, get_doc);
Py_XSETREF(self->prop_doc, prop_doc);
}
else {
/* If this is a property subclass, put __doc__
in dict of the subclass instance instead,
otherwise it gets shadowed by __doc__ in the
class's dict. */
int err = PyObject_SetAttr(
(PyObject *)self, &_Py_ID(__doc__), get_doc);
Py_XDECREF(get_doc);
(PyObject *)self, &_Py_ID(__doc__), prop_doc);
Py_XDECREF(prop_doc);
if (err < 0)
return -1;
}
Expand Down
0