Merged the int/long unification branch, by very crude means (sorry Thomas!).
I banged on the code (beyond what's in that branch) to make fewer tests fail;
the only tests that fail now are:
  test_descr -- can't pickle ints?!
  test_pickletools -- ???
  test_socket -- See python.org/sf/1619659
  test_sqlite -- ???
I'll deal with those later.
diff --git a/Python/marshal.c b/Python/marshal.c
index 1819eac..fd1bd72 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -144,31 +144,34 @@
 	else if (v == Py_True) {
 	        w_byte(TYPE_TRUE, p);
 	}
-	else if (PyInt_Check(v)) {
-		long x = PyInt_AS_LONG((PyIntObject *)v);
+	else if (PyLong_Check(v)) {
+		long x = PyLong_AsLong(v);
+		if ((x == -1)  && PyErr_Occurred()) {
+			PyLongObject *ob = (PyLongObject *)v;
+			PyErr_Clear();
+			w_byte(TYPE_LONG, p);
+			n = ob->ob_size;
+			w_long((long)n, p);
+			if (n < 0)
+				n = -n;
+			for (i = 0; i < n; i++)
+				w_short(ob->ob_digit[i], p);
+		} 
+		else {
 #if SIZEOF_LONG > 4
-		long y = Py_ARITHMETIC_RIGHT_SHIFT(long, x, 31);
-		if (y && y != -1) {
-			w_byte(TYPE_INT64, p);
-			w_long64(x, p);
-		}
-		else
+			long y = Py_ARITHMETIC_RIGHT_SHIFT(long, x, 31);
+			if (y && y != -1) {
+				w_byte(TYPE_INT64, p);
+				w_long64(x, p);
+			}
+			else
 #endif
 			{
-			w_byte(TYPE_INT, p);
-			w_long(x, p);
+				w_byte(TYPE_INT, p);
+				w_long(x, p);
+			}
 		}
 	}
-	else if (PyLong_Check(v)) {
-		PyLongObject *ob = (PyLongObject *)v;
-		w_byte(TYPE_LONG, p);
-		n = ob->ob_size;
-		w_long((long)n, p);
-		if (n < 0)
-			n = -n;
-		for (i = 0; i < n; i++)
-			w_short(ob->ob_digit[i], p);
-	}
 	else if (PyFloat_Check(v)) {
 		if (p->version > 1) {
 			unsigned char buf[8];