Skip to content
Merged
Changes from 1 commit
Commits
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
Fix introduced refleak
  • Loading branch information
sizmailov committed Apr 7, 2022
commit 009a9f3ef8799a53fda9b2bda235099f7cbbf32f
38 changes: 19 additions & 19 deletions Objects/descrobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1791,33 +1791,33 @@ property_init_impl(propertyobject *self, PyObject *fget, PyObject *fset,
self->getter_doc = 0;
PyObject *prop_doc = NULL;

if (doc != NULL && doc != Py_None) {
prop_doc = doc;
Py_XINCREF(prop_doc);
}
/* if no docstring given and the getter has one, use that one */
if ((doc == NULL || doc == Py_None) && fget != NULL) {
else if (fget != NULL) {
int rc = _PyObject_LookupAttr(fget, &_Py_ID(__doc__), &prop_doc);
if (rc <= 0) {
return rc;
}
self->getter_doc = 1;
Comment thread
sizmailov marked this conversation as resolved.
Outdated
}
else {
prop_doc = doc;
Py_XINCREF(prop_doc);
}


Comment thread
sizmailov marked this conversation as resolved.
if (Py_IS_TYPE(self, &PyProperty_Type)) {
Py_XSETREF(self->prop_doc, prop_doc);
}
else if (prop_doc != NULL) {
/* 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__), prop_doc);
Py_XDECREF(prop_doc);
if (err < 0)
return -1;
if (prop_doc != NULL && prop_doc != Py_None) {
Comment thread
JelleZijlstra marked this conversation as resolved.
Outdated
if (Py_IS_TYPE(self, &PyProperty_Type)) {
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__), prop_doc);
Py_XDECREF(prop_doc);
if (err < 0)
return -1;
}
}

return 0;
Expand Down