Patch #1024670: Support int objects in PyLong_AsUnsignedLong[Mask].
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 0103e5c..0ee9a69 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -245,6 +245,15 @@
 	int i;
 
 	if (vv == NULL || !PyLong_Check(vv)) {
+		if (vv != NULL && PyInt_Check(vv)) {
+			long val = PyInt_AsLong(vv);
+			if (val < 0) {
+				PyErr_SetString(PyExc_OverflowError,
+				"can't convert negative value to unsigned long");
+				return (unsigned long) -1;
+			}
+			return val;
+		}
 		PyErr_BadInternalCall();
 		return (unsigned long) -1;
 	}
@@ -279,6 +288,8 @@
 	int i, sign;
 
 	if (vv == NULL || !PyLong_Check(vv)) {
+		if (vv != NULL && PyInt_Check(vv))
+			return PyInt_AsUnsignedLongMask(vv);
 		PyErr_BadInternalCall();
 		return (unsigned long) -1;
 	}