Merged revisions 72299 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72299 | r.david.murray | 2009-05-04 18:16:24 -0400 (Mon, 04 May 2009) | 7 lines

  Fix issue 5890: (property subclass shadows __doc__ string) by inserting
  the __doc__ into the subclass instance __dict__.  The fix refactors
  property_copy to call property_init in such a way that the __doc__
  logic is re-executed correctly when getter_doc is 1, thus simplifying
  property_copy.
........
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 536e5a8..f6f5976 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -1233,25 +1233,19 @@
 	}
 	if (doc == NULL || doc == Py_None) {
 		Py_XDECREF(doc);
-		doc = pold->prop_doc ? pold->prop_doc : Py_None;
+		if (pold->getter_doc && get != Py_None) {
+			/* make _init use __doc__ from getter */
+			doc = Py_None;
+		}
+		else {
+			doc = pold->prop_doc ? pold->prop_doc : Py_None;
+		}
 	}
-	
+
 	new =  PyObject_CallFunction(type, "OOOO", get, set, del, doc);
 	Py_DECREF(type);
 	if (new == NULL)
 		return NULL;
-	pnew = (propertyobject *)new;
-	
-	if (pold->getter_doc && get != Py_None) {
-		PyObject *get_doc = PyObject_GetAttrString(get, "__doc__");
-		if (get_doc != NULL) {
-			Py_XDECREF(pnew->prop_doc);
-			pnew->prop_doc = get_doc;  /* get_doc already INCREF'd by GetAttr */
-			pnew->getter_doc = 1;
-		} else {
-			PyErr_Clear();
-		}
-	}
 	return new;
 }
 
@@ -1288,8 +1282,21 @@
 	if ((doc == NULL || doc == Py_None) && get != NULL) {
 		PyObject *get_doc = PyObject_GetAttrString(get, "__doc__");
 		if (get_doc != NULL) {
-			Py_XDECREF(prop->prop_doc);
-			prop->prop_doc = get_doc;  /* get_doc already INCREF'd by GetAttr */
+			/* get_doc already INCREF'd by GetAttr */
+			if (Py_TYPE(self)==&PyProperty_Type) {
+				Py_XDECREF(prop->prop_doc);
+				prop->prop_doc = get_doc;
+			} else {
+				/* Put __doc__ in dict of the subclass instance instead,
+				otherwise it gets shadowed by class's __doc__. */
+				if (PyObject_SetAttrString(self, "__doc__", get_doc) != 0)
+				{
+					/* DECREF for props handled by _dealloc */
+					Py_DECREF(get_doc);
+					return -1;
+	                        }
+                                Py_DECREF(get_doc);
+			}
 			prop->getter_doc = 1;
 		} else {
 			PyErr_Clear();