diff Objects/tupleobject.c @ 36519:d6d415df0df0 legacy-trunk

Use Py_ssize_t for counts and sizes. Convert Py_ssize_t using PyInt_FromSsize_t
author Martin v. Löwis <martin@v.loewis.de>
date Thu, 16 Feb 2006 14:32:27 +0000
parents 7fdc639bc5b4
children dba6494735d0
line wrap: on
line diff
--- a/Objects/tupleobject.c	Thu Feb 16 14:30:23 2006 +0000
+++ b/Objects/tupleobject.c	Thu Feb 16 14:32:27 2006 +0000
@@ -278,7 +278,8 @@
 		if (y == -1)
 			return -1;
 		x = (x ^ y) * mult;
-		mult += 82520L + len + len;
+		/* the cast might truncate len; that doesn't change hash stability */
+		mult += (long)(82520L + len + len);
 	}
 	x += 97531L;
 	if (x == -1)
@@ -850,10 +851,10 @@
 static PyObject *
 tupleiter_len(tupleiterobject *it)
 {
-	long len = 0;
+	Py_ssize_t len = 0;
 	if (it->it_seq)
 		len = PyTuple_GET_SIZE(it->it_seq) - it->it_index;
-	return PyInt_FromLong(len);
+	return PyInt_FromSsize_t(len);
 }
 
 PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it)).");