merge from trunk
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 6f3ba1b..8a65b0c 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1870,16 +1870,18 @@
 "D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D");
 
 PyDoc_STRVAR(pop__doc__,
-"D.pop(k[,d]) -> v, remove specified key and return the corresponding value\n\
+"D.pop(k[,d]) -> v, remove specified key and return the corresponding value.\n\
 If key is not found, d is returned if given, otherwise KeyError is raised");
 
 PyDoc_STRVAR(popitem__doc__,
 "D.popitem() -> (k, v), remove and return some (key, value) pair as a\n\
-2-tuple; but raise KeyError if D is empty");
+2-tuple; but raise KeyError if D is empty.");
 
 PyDoc_STRVAR(update__doc__,
-"D.update(E, **F) -> None.  Update D from E and F: for k in E: D[k] = E[k]\
-\n(if E has keys else: for (k, v) in E: D[k] = v) then: for k in F: D[k] = F[k]");
+"D.update(E, **F) -> None.  Update D from dict/iterable E and F.\n"
+"If E has a .keys() method, does:     for k in E: D[k] = E[k]\n\
+If E lacks .keys() method, does:     for (k, v) in E: D[k] = v\n\
+In either case, this is followed by: for k in F: D[k] = F[k]");
 
 PyDoc_STRVAR(fromkeys__doc__,
 "dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.\n\
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 6bf65e0..89eac64 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1457,7 +1457,7 @@
 #ifdef Py_NAN
 	if (Py_IS_NAN(self)) {
 	  PyErr_SetString(PyExc_ValueError,
-			  "Cannot pass nan to float.as_integer_ratio.");
+			  "Cannot pass NaN to float.as_integer_ratio.");
 	  return NULL;
 	}
 #endif
@@ -1516,7 +1516,7 @@
 "\n"
 "Returns a pair of integers, whose ratio is exactly equal to the original\n"
 "float and with a positive denominator.\n"
-"Raises OverflowError on infinities and a ValueError on nans.\n"
+"Raises OverflowError on infinities and a ValueError on NaNs.\n"
 "\n"
 ">>> (10.0).as_integer_ratio()\n"
 "(10, 1)\n"
diff --git a/Objects/listobject.c b/Objects/listobject.c
index dc910f6..d5acec1 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -2286,11 +2286,14 @@
 PyDoc_STRVAR(insert_doc,
 "L.insert(index, object) -- insert object before index");
 PyDoc_STRVAR(pop_doc,
-"L.pop([index]) -> item -- remove and return item at index (default last)");
+"L.pop([index]) -> item -- remove and return item at index (default last).\n"
+"Raises IndexError if list is empty or index is out of range.");
 PyDoc_STRVAR(remove_doc,
-"L.remove(value) -- remove first occurrence of value");
+"L.remove(value) -- remove first occurrence of value.\n"
+"Raises ValueError if the value is not present.");
 PyDoc_STRVAR(index_doc,
-"L.index(value, [start, [stop]]) -> integer -- return first index of value");
+"L.index(value, [start, [stop]]) -> integer -- return first index of value.\n"
+"Raises ValueError if the value is not present.");
 PyDoc_STRVAR(count_doc,
 "L.count(value) -> integer -- return number of occurrences of value");
 PyDoc_STRVAR(reverse_doc,
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 1054166..d24e1af 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -746,7 +746,8 @@
 	return key;
 }
 
-PyDoc_STRVAR(pop_doc, "Remove and return an arbitrary set element.");
+PyDoc_STRVAR(pop_doc, "Remove and return an arbitrary set element.\n\
+Raises KeyError if the set is empty.");
 
 static int
 set_traverse(PySetObject *so, visitproc visit, void *arg)
@@ -1861,7 +1862,7 @@
 static PyObject *
 set_remove(PySetObject *so, PyObject *key)
 {
-	PyObject *tmpkey, *result;
+	PyObject *tmpkey;
 	int rv;
 
 	rv = set_discard_key(so, key);
@@ -1873,11 +1874,14 @@
 		if (tmpkey == NULL)
 			return NULL;
 		set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key);
-		result = set_remove(so, tmpkey);
+		rv = set_discard_key(so, tmpkey);
 		set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key);
 		Py_DECREF(tmpkey);
-		return result;
-	} else if (rv == DISCARD_NOTFOUND) {
+		if (rv == -1)
+			return NULL;
+	} 
+
+	if (rv == DISCARD_NOTFOUND) {
 		set_key_error(key);
 		return NULL;
 	}
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 963d90e..679ba8f 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -694,7 +694,9 @@
 }
 
 PyDoc_STRVAR(index_doc,
-"T.index(value, [start, [stop]]) -> integer -- return first index of value");
+"T.index(value, [start, [stop]]) -> integer -- return first index of value.\n"
+"Raises ValueError if the value is not present."
+);
 PyDoc_STRVAR(count_doc,
 "T.count(value) -> integer -- return number of occurrences of value");
 PyDoc_STRVAR(sizeof_doc,
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 0c5c6ef..ecd44cb 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -7300,7 +7300,7 @@
 PyDoc_STRVAR(ljust__doc__,
 "S.ljust(width[, fillchar]) -> str\n\
 \n\
-Return S left justified in a Unicode string of length width. Padding is\n\
+Return S left-justified in a Unicode string of length width. Padding is\n\
 done using the specified fill character (default is a space).");
 
 static PyObject *
@@ -7815,7 +7815,7 @@
 PyDoc_STRVAR(rjust__doc__,
 "S.rjust(width[, fillchar]) -> str\n\
 \n\
-Return S right justified in a string of length width. Padding is\n\
+Return S right-justified in a string of length width. Padding is\n\
 done using the specified fill character (default is a space).");
 
 static PyObject *
@@ -7945,7 +7945,7 @@
 \n\
 Search for the separator sep in S, and return the part before it,\n\
 the separator itself, and the part after it.  If the separator is not\n\
-found, returns S and two empty strings.");
+found, return S and two empty strings.");
 
 static PyObject*
 unicode_partition(PyUnicodeObject *self, PyObject *separator)
@@ -7958,7 +7958,7 @@
 \n\
 Search for the separator sep in S, starting at the end of S, and return\n\
 the part before it, the separator itself, and the part after it.  If the\n\
-separator is not found, returns two empty strings and S.");
+separator is not found, return two empty strings and S.");
 
 static PyObject*
 unicode_rpartition(PyUnicodeObject *self, PyObject *separator)