Issue #8300 (__index__ handling in struct.pack): Remove redundant check
and improve test coverage.  Thanks Meador Inge for the patch.
diff --git a/Modules/_struct.c b/Modules/_struct.c
index fe54a47..441da03 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -123,12 +123,6 @@
 			w = PyNumber_Index(v);
 			if (w != NULL) {
 				v = w;
-				if (!PyInt_Check(v) && !PyLong_Check(v)) {
-					PyErr_SetString(PyExc_TypeError,
-							"__index__ method "
-							"returned non-integer");
-					return NULL;
-				}
 				/* successfully converted to an integer */
 				converted = 1;
 			}
@@ -175,6 +169,7 @@
 		/* Ensure we own a reference to v. */
 		Py_INCREF(v);
 
+	assert(PyInt_Check(v) || PyLong_Check(v));
 	if (PyInt_Check(v)) {
 		r = PyLong_FromLong(PyInt_AS_LONG(v));
 		Py_DECREF(v);