Commits

Mark Dickinson  committed 75e1b8c

Issue #6985: number of range() items should be constrained to lie
in a Py_ssize_t, not an int.

  • Participants
  • Parent commits 8180925
  • Branches legacy-trunk

Comments (0)

Files changed (1)

File Python/bltinmodule.c

 	PyObject *curnum = NULL;
 	PyObject *v = NULL;
 	long bign;
-	int i, n;
+	Py_ssize_t i, n;
 	int cmp_result;
 
 	PyObject *zero = PyLong_FromLong(0);
 		Py_DECREF(neg_istep);
 	}
 
-	n = (int)bign;
+	n = (Py_ssize_t)bign;
 	if (bign < 0 || (long)n != bign) {
 		PyErr_SetString(PyExc_OverflowError,
 				"range() result has too many items");
 {
 	long ilow = 0, ihigh = 0, istep = 1;
 	long bign;
-	int i, n;
+	Py_ssize_t i, n;
 
 	PyObject *v;
 
 		bign = get_len_of_range(ilow, ihigh, istep);
 	else
 		bign = get_len_of_range(ihigh, ilow, -istep);
-	n = (int)bign;
+	n = (Py_ssize_t)bign;
 	if (bign < 0 || (long)n != bign) {
 		PyErr_SetString(PyExc_OverflowError,
 				"range() result has too many items");