diff -r 0879f2c53289 Objects/descrobject.c --- a/Objects/descrobject.c Fri Jul 31 09:02:09 2015 +1200 +++ b/Objects/descrobject.c Fri Jul 31 12:49:44 2015 -0400 @@ -1480,6 +1480,7 @@ PyObject *get = NULL, *set = NULL, *del = NULL, *doc = NULL; static char *kwlist[] = {"fget", "fset", "fdel", "doc", 0}; propertyobject *prop = (propertyobject *)self; + _Py_IDENTIFIER(__doc__); if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO:property", kwlist, &get, &set, &del, &doc)) @@ -1505,23 +1506,10 @@ /* if no docstring given and the getter has one, use that one */ if ((doc == NULL || doc == Py_None) && get != NULL) { - _Py_IDENTIFIER(__doc__); PyObject *get_doc = _PyObject_GetAttrId(get, &PyId___doc__); if (get_doc) { - if (Py_TYPE(self) == &PyProperty_Type) { - Py_XDECREF(prop->prop_doc); - prop->prop_doc = get_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_SetAttrId(self, &PyId___doc__, get_doc); - Py_DECREF(get_doc); - if (err < 0) - return -1; - } + Py_XDECREF(prop->prop_doc); + prop->prop_doc = get_doc; prop->getter_doc = 1; } else if (PyErr_ExceptionMatches(PyExc_Exception)) { @@ -1532,6 +1520,17 @@ } } + if (Py_TYPE(self) != &PyProperty_Type) { + /* 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_SetAttrId(self, &PyId___doc__, prop->prop_doc); + + if (err < 0) + return -1; + } + return 0; }