Change int to Py_ssize_t in several places.
Add (int) casts to silence compiler warnings.
Raise Python exceptions for overflows.
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 6072c08..9837e38 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -4244,7 +4244,8 @@
}
}
else if (! PyErr_Occurred()) {
- result = _PySequence_IterSearch(self, value,
+ /* Possible results: -1 and 1 */
+ result = (int)_PySequence_IterSearch(self, value,
PY_ITERSEARCH_CONTAINS);
}
return result;
@@ -4880,7 +4881,7 @@
* never happened.
*/
{
- int refcnt = self->ob_refcnt;
+ Py_ssize_t refcnt = self->ob_refcnt;
_Py_NewReference(self);
self->ob_refcnt = refcnt;
}