Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 59674bf..18d3b90 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -925,7 +925,7 @@
Py_DECREF(args);
if (res == NULL)
return -1;
- if (!PyInt_CheckExact(res)) {
+ if (!PyLong_CheckExact(res)) {
PyErr_Format(PyExc_TypeError,
"comparison function must return int, not %.200s",
res->ob_type->tp_name);
@@ -934,6 +934,10 @@
}
i = PyLong_AsLong(res);
Py_DECREF(res);
+ if (i == -1 && PyErr_Occurred()) {
+ /* Overflow in long conversion. */
+ return -1;
+ }
return i < 0;
}