[Python-checkins] r41971 - in python/branches/ssize_t: Include/abstract.h Include/bufferobject.h Include/listobject.h Include/pystrtod.h Include/stringobject.h Include/tupleobject.h Objects/abstract.c Objects/bufferobject.c Objects/classobject.c Objects/codeobject.c Objects/descrobject.c Objects/dictobject.c Objects/enumobject.c Objects/fileobject.c Objects/frameobject.c Objects/funcobject.c Objects/iterobject.c Objects/listobject.c Objects/methodobject.c Objects/object.c Objects/setobject.c Objects/stringobject.c Objects/structseq.c Objects/tupleobject.c Objects/typeobject.c Objects/weakrefobject.c Python/pystrtod.c

neal.norwitz python-checkins at python.org
Sun Jan 8 06:48:20 CET 2006


Author: neal.norwitz
Date: Sun Jan  8 06:48:15 2006
New Revision: 41971

Modified:
   python/branches/ssize_t/Include/abstract.h
   python/branches/ssize_t/Include/bufferobject.h
   python/branches/ssize_t/Include/listobject.h
   python/branches/ssize_t/Include/pystrtod.h
   python/branches/ssize_t/Include/stringobject.h
   python/branches/ssize_t/Include/tupleobject.h
   python/branches/ssize_t/Objects/abstract.c
   python/branches/ssize_t/Objects/bufferobject.c
   python/branches/ssize_t/Objects/classobject.c
   python/branches/ssize_t/Objects/codeobject.c
   python/branches/ssize_t/Objects/descrobject.c
   python/branches/ssize_t/Objects/dictobject.c
   python/branches/ssize_t/Objects/enumobject.c
   python/branches/ssize_t/Objects/fileobject.c
   python/branches/ssize_t/Objects/frameobject.c
   python/branches/ssize_t/Objects/funcobject.c
   python/branches/ssize_t/Objects/iterobject.c
   python/branches/ssize_t/Objects/listobject.c
   python/branches/ssize_t/Objects/methodobject.c
   python/branches/ssize_t/Objects/object.c
   python/branches/ssize_t/Objects/setobject.c
   python/branches/ssize_t/Objects/stringobject.c
   python/branches/ssize_t/Objects/structseq.c
   python/branches/ssize_t/Objects/tupleobject.c
   python/branches/ssize_t/Objects/typeobject.c
   python/branches/ssize_t/Objects/weakrefobject.c
   python/branches/ssize_t/Python/pystrtod.c
Log:
Get rid of a bunch of warnings mostly by converting int -> Py_ssize_t

Modified: python/branches/ssize_t/Include/abstract.h
==============================================================================
--- python/branches/ssize_t/Include/abstract.h	(original)
+++ python/branches/ssize_t/Include/abstract.h	Sun Jan  8 06:48:15 2006
@@ -422,7 +422,7 @@
      PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o);
 #define PyObject_Length PyObject_Size
 
-     PyAPI_FUNC(int) _PyObject_LengthCue(PyObject *o);
+     PyAPI_FUNC(Py_ssize_t) _PyObject_LengthCue(PyObject *o);
 
        /*
          Return the size of object o.  If the object, o, provides
@@ -513,7 +513,7 @@
 
      PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj,
 					   void **buffer,
-					   int *buffer_len);
+					   Py_ssize_t *buffer_len);
 
        /* 
 	  Takes an arbitrary object which must support the (writeable,

Modified: python/branches/ssize_t/Include/bufferobject.h
==============================================================================
--- python/branches/ssize_t/Include/bufferobject.h	(original)
+++ python/branches/ssize_t/Include/bufferobject.h	Sun Jan  8 06:48:15 2006
@@ -17,15 +17,15 @@
 #define Py_END_OF_BUFFER	(-1)
 
 PyAPI_FUNC(PyObject *) PyBuffer_FromObject(PyObject *base,
-                                                 int offset, Py_ssize_t size);
+                                           Py_ssize_t offset, Py_ssize_t size);
 PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteObject(PyObject *base,
-                                                          int offset,
-                                                          Py_ssize_t size);
+                                                    Py_ssize_t offset,
+                                                    Py_ssize_t size);
 
 PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, Py_ssize_t size);
 PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size);
 
-PyAPI_FUNC(PyObject *) PyBuffer_New(int size);
+PyAPI_FUNC(PyObject *) PyBuffer_New(Py_ssize_t size);
 
 #ifdef __cplusplus
 }

Modified: python/branches/ssize_t/Include/listobject.h
==============================================================================
--- python/branches/ssize_t/Include/listobject.h	(original)
+++ python/branches/ssize_t/Include/listobject.h	Sun Jan  8 06:48:15 2006
@@ -35,7 +35,7 @@
      * Items must normally not be NULL, except during construction when
      * the list is not yet visible outside the function that builds it.
      */
-    int allocated;
+    Py_ssize_t allocated;
 } PyListObject;
 
 PyAPI_DATA(PyTypeObject) PyList_Type;

Modified: python/branches/ssize_t/Include/pystrtod.h
==============================================================================
--- python/branches/ssize_t/Include/pystrtod.h	(original)
+++ python/branches/ssize_t/Include/pystrtod.h	Sun Jan  8 06:48:15 2006
@@ -8,7 +8,7 @@
 
 PyAPI_FUNC(double) PyOS_ascii_strtod(const char *str, char **ptr);
 PyAPI_FUNC(double) PyOS_ascii_atof(const char *str);
-PyAPI_FUNC(char *) PyOS_ascii_formatd(char *buffer, int buf_len,  const char *format, double d);
+PyAPI_FUNC(char *) PyOS_ascii_formatd(char *buffer, size_t buf_len,  const char *format, double d);
 
 
 #ifdef __cplusplus

Modified: python/branches/ssize_t/Include/stringobject.h
==============================================================================
--- python/branches/ssize_t/Include/stringobject.h	(original)
+++ python/branches/ssize_t/Include/stringobject.h	Sun Jan  8 06:48:15 2006
@@ -64,7 +64,7 @@
 				Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
 PyAPI_FUNC(PyObject *) PyString_FromFormat(const char*, ...)
 				Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
-PyAPI_FUNC(int) PyString_Size(PyObject *);
+PyAPI_FUNC(Py_ssize_t) PyString_Size(PyObject *);
 PyAPI_FUNC(char *) PyString_AsString(PyObject *);
 PyAPI_FUNC(PyObject *) PyString_Repr(PyObject *, int);
 PyAPI_FUNC(void) PyString_Concat(PyObject **, PyObject *);

Modified: python/branches/ssize_t/Include/tupleobject.h
==============================================================================
--- python/branches/ssize_t/Include/tupleobject.h	(original)
+++ python/branches/ssize_t/Include/tupleobject.h	Sun Jan  8 06:48:15 2006
@@ -41,8 +41,8 @@
 PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, Py_ssize_t);
 PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
 PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
-PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, int);
-PyAPI_FUNC(PyObject *) PyTuple_Pack(int, ...);
+PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t);
+PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...);
 
 /* Macro, trading safety for speed */
 #define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i])

Modified: python/branches/ssize_t/Objects/abstract.c
==============================================================================
--- python/branches/ssize_t/Objects/abstract.c	(original)
+++ python/branches/ssize_t/Objects/abstract.c	Sun Jan  8 06:48:15 2006
@@ -81,7 +81,7 @@
 }
 #define PyObject_Length PyObject_Size
 
-int
+Py_ssize_t
 _PyObject_LengthCue(PyObject *o)
 {
 	Py_ssize_t rv = PyObject_Size(o);
@@ -94,7 +94,7 @@
 		PyErr_Fetch(&err_type, &err_value, &err_tb);
 		ro = PyObject_CallMethod(o, "_length_cue", NULL);
 		if (ro != NULL) {
-			rv = (int)PyInt_AsLong(ro);
+			rv = PyInt_AsLong(ro);
 			Py_DECREF(ro);
 			Py_XDECREF(err_type);
 			Py_XDECREF(err_value);
@@ -297,11 +297,11 @@
 
 int PyObject_AsWriteBuffer(PyObject *obj,
 			   void **buffer,
-			   int *buffer_len)
+			   Py_ssize_t *buffer_len)
 {
 	PyBufferProcs *pb;
 	void*pp;
-	int len;
+	Py_ssize_t len;
 
 	if (obj == NULL || buffer == NULL || buffer_len == NULL) {
 		null_error();
@@ -415,7 +415,7 @@
 				binaryfunc slot;
 				slot = NB_BINOP(mv, op_slot);
 				if (slot) {
-					PyObject *x = slot(v, w);
+					x = slot(v, w);
 					Py_DECREF(v);
 					Py_DECREF(w);
 					return x;
@@ -1260,7 +1260,7 @@
 }
 
 static PyObject *
-sliceobj_from_intint(int i, int j)
+sliceobj_from_intint(Py_ssize_t i, Py_ssize_t j)
 {
 	PyObject *start, *end, *slice;
 	start = PyInt_FromLong((long)i);
@@ -1438,9 +1438,9 @@
 PySequence_Tuple(PyObject *v)
 {
 	PyObject *it;  /* iter(v) */
-	int n;         /* guess for result tuple size */
+	Py_ssize_t n;         /* guess for result tuple size */
 	PyObject *result;
-	int j;
+	Py_ssize_t j;
 
 	if (v == NULL)
 		return null_error();
@@ -1486,7 +1486,7 @@
 			break;
 		}
 		if (j >= n) {
-			int oldn = n;
+			Py_ssize_t oldn = n;
 			/* The over-allocation strategy can grow a bit faster
 			   than for lists because unlike lists the 
 			   over-allocation isn't permanent -- we reclaim
@@ -2053,7 +2053,7 @@
 abstract_issubclass(PyObject *derived, PyObject *cls)
 {
 	PyObject *bases;
-	int i, n;
+	Py_ssize_t i, n;
 	int r = 0;
 
 
@@ -2137,7 +2137,7 @@
 		}
 	}
 	else if (PyTuple_Check(cls)) {
-		int i, n;
+		Py_ssize_t i, n;
 
                 if (!recursion_depth) {
                     PyErr_SetString(PyExc_RuntimeError,
@@ -2191,8 +2191,8 @@
 			return -1;
 
 		if (PyTuple_Check(cls)) {
-			int i;
-			int n = PyTuple_GET_SIZE(cls);
+			Py_ssize_t i;
+			Py_ssize_t n = PyTuple_GET_SIZE(cls);
 
                         if (!recursion_depth) {
                             PyErr_SetString(PyExc_RuntimeError,

Modified: python/branches/ssize_t/Objects/bufferobject.c
==============================================================================
--- python/branches/ssize_t/Objects/bufferobject.c	(original)
+++ python/branches/ssize_t/Objects/bufferobject.c	Sun Jan  8 06:48:15 2006
@@ -8,15 +8,15 @@
 	PyObject_HEAD
 	PyObject *b_base;
 	void *b_ptr;
-	int b_size;
-	int b_offset;
+	Py_ssize_t b_size;
+	Py_ssize_t b_offset;
 	int b_readonly;
 	long b_hash;
 } PyBufferObject;
 
 
 static int
-get_buf(PyBufferObject *self, void **ptr, int *size)
+get_buf(PyBufferObject *self, void **ptr, Py_ssize_t *size)
 {
 	if (self->b_base == NULL) {
 		assert (ptr != NULL);
@@ -24,7 +24,7 @@
 		*size = self->b_size;
 	}
 	else {
-		int count, offset;
+		Py_ssize_t count, offset;
 		getreadbufferproc proc;
 		PyBufferProcs *bp = self->b_base->ob_type->tp_as_buffer;
 		if ((*bp->bf_getsegcount)(self->b_base, NULL) != 1) {
@@ -56,7 +56,7 @@
 
 
 static PyObject *
-buffer_from_memory(PyObject *base, Py_ssize_t size, int offset, void *ptr,
+buffer_from_memory(PyObject *base, Py_ssize_t size, Py_ssize_t offset, void *ptr,
 		   int readonly)
 {
 	PyBufferObject * b;
@@ -88,7 +88,7 @@
 }
 
 static PyObject *
-buffer_from_object(PyObject *base, int size, int offset, int readonly)
+buffer_from_object(PyObject *base, Py_ssize_t size, Py_ssize_t offset, int readonly)
 {
 	if (offset < 0) {
 		PyErr_SetString(PyExc_ValueError,
@@ -99,7 +99,7 @@
 		/* another buffer, refer to the base object */
 		PyBufferObject *b = (PyBufferObject *)base;
 		if (b->b_size != Py_END_OF_BUFFER) {
-			int base_size = b->b_size - offset;
+			Py_ssize_t base_size = b->b_size - offset;
 			if (base_size < 0)
 				base_size = 0;
 			if (size == Py_END_OF_BUFFER || size > base_size)
@@ -113,7 +113,7 @@
 
 
 PyObject *
-PyBuffer_FromObject(PyObject *base, int offset, Py_ssize_t size)
+PyBuffer_FromObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)
 {
 	PyBufferProcs *pb = base->ob_type->tp_as_buffer;
 
@@ -129,7 +129,7 @@
 }
 
 PyObject *
-PyBuffer_FromReadWriteObject(PyObject *base, int offset, Py_ssize_t size)
+PyBuffer_FromReadWriteObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)
 {
 	PyBufferProcs *pb = base->ob_type->tp_as_buffer;
 
@@ -157,7 +157,7 @@
 }
 
 PyObject *
-PyBuffer_New(int size)
+PyBuffer_New(Py_ssize_t size)
 {
 	PyObject *o;
 	PyBufferObject * b;
@@ -167,6 +167,7 @@
 				"size must be zero or positive");
 		return NULL;
 	}
+	/* XXX: check for overflow in multiply */
 	/* Inline PyObject_New */
 	o = PyObject_MALLOC(sizeof(*b) + size);
 	if ( o == NULL )
@@ -189,13 +190,13 @@
 buffer_new(PyTypeObject *type, PyObject *args, PyObject *kw)
 {
 	PyObject *ob;
-	int offset = 0;
-	int size = Py_END_OF_BUFFER;
+	Py_ssize_t offset = 0;
+	Py_ssize_t size = Py_END_OF_BUFFER;
 
 	if (!_PyArg_NoKeywords("buffer()", kw))
 		return NULL;
 
-	if (!PyArg_ParseTuple(args, "O|ii:buffer", &ob, &offset, &size))
+	if (!PyArg_ParseTuple(args, "O|ll:buffer", &ob, &offset, &size))
 	    return NULL;
 	return PyBuffer_FromObject(ob, offset, size);
 }
@@ -220,7 +221,8 @@
 buffer_compare(PyBufferObject *self, PyBufferObject *other)
 {
 	void *p1, *p2;
-	int len_self, len_other, min_len, cmp;
+	Py_ssize_t len_self, len_other, min_len;
+	int cmp;
 
 	if (!get_buf(self, &p1, &len_self))
 		return -1;
@@ -238,17 +240,17 @@
 static PyObject *
 buffer_repr(PyBufferObject *self)
 {
-	char *status = self->b_readonly ? "read-only" : "read-write";
+	const char *status = self->b_readonly ? "read-only" : "read-write";
 
 	if ( self->b_base == NULL )
-		return PyString_FromFormat("<%s buffer ptr %p, size %d at %p>",
+		return PyString_FromFormat("<%s buffer ptr %p, size %ld at %p>",
 					   status,
 					   self->b_ptr,
 					   self->b_size,
 					   self);
 	else
 		return PyString_FromFormat(
-			"<%s buffer for %p, size %d, offset %d at %p>",
+			"<%s buffer for %p, size %ld, offset %ld at %p>",
 			status,
 			self->b_base,
 			self->b_size,
@@ -260,8 +262,8 @@
 buffer_hash(PyBufferObject *self)
 {
 	void *ptr;
-	int size;
-	register int len;
+	Py_ssize_t size;
+	register Py_ssize_t len;
 	register unsigned char *p;
 	register long x;
 
@@ -300,7 +302,7 @@
 buffer_str(PyBufferObject *self)
 {
 	void *ptr;
-	int size;
+	Py_ssize_t size;
 	if (!get_buf(self, &ptr, &size))
 		return NULL;
 	return PyString_FromStringAndSize(ptr, size);
@@ -312,7 +314,7 @@
 buffer_length(PyBufferObject *self)
 {
 	void *ptr;
-	int size;
+	Py_ssize_t size;
 	if (!get_buf(self, &ptr, &size))
 		return -1;
 	return size;
@@ -325,7 +327,7 @@
 	void *ptr1, *ptr2;
 	char *p;
 	PyObject *ob;
-	int size, count;
+	Py_ssize_t size, count;
 
 	if ( pb == NULL ||
 	     pb->bf_getreadbuffer == NULL ||
@@ -374,7 +376,7 @@
 	PyObject *ob;
 	register char *p;
 	void *ptr;
-	int size;
+	Py_ssize_t size;
 
 	if ( count < 0 )
 		count = 0;
@@ -401,7 +403,7 @@
 buffer_item(PyBufferObject *self, Py_ssize_t idx)
 {
 	void *ptr;
-	int size;
+	Py_ssize_t size;
 	if (!get_buf(self, &ptr, &size))
 		return NULL;
 	if ( idx < 0 || idx >= size ) {
@@ -415,7 +417,7 @@
 buffer_slice(PyBufferObject *self, Py_ssize_t left, Py_ssize_t right)
 {
 	void *ptr;
-	int size;
+	Py_ssize_t size;
 	if (!get_buf(self, &ptr, &size))
 		return NULL;
 	if ( left < 0 )
@@ -435,8 +437,8 @@
 {
 	PyBufferProcs *pb;
 	void *ptr1, *ptr2;
-	int size;
-	int count;
+	Py_ssize_t size;
+	Py_ssize_t count;
 
 	if ( self->b_readonly ) {
 		PyErr_SetString(PyExc_TypeError,
@@ -486,9 +488,9 @@
 {
 	PyBufferProcs *pb;
 	void *ptr1, *ptr2;
-	int size;
-	int slice_len;
-	int count;
+	Py_ssize_t size;
+	Py_ssize_t slice_len;
+	Py_ssize_t count;
 
 	if ( self->b_readonly ) {
 		PyErr_SetString(PyExc_TypeError,
@@ -541,10 +543,10 @@
 
 /* Buffer methods */
 
-static int
+static Py_ssize_t
 buffer_getreadbuf(PyBufferObject *self, int idx, void **pp)
 {
-	int size;
+	Py_ssize_t size;
 	if ( idx != 0 ) {
 		PyErr_SetString(PyExc_SystemError,
 				"accessing non-existent buffer segment");
@@ -555,7 +557,7 @@
 	return size;
 }
 
-static int
+static Py_ssize_t
 buffer_getwritebuf(PyBufferObject *self, int idx, void **pp)
 {
 	if ( self->b_readonly )
@@ -567,10 +569,10 @@
 }
 
 static int
-buffer_getsegcount(PyBufferObject *self, int *lenp)
+buffer_getsegcount(PyBufferObject *self, Py_ssize_t *lenp)
 {
 	void *ptr;
-	int size;
+	Py_ssize_t size;
 	if (!get_buf(self, &ptr, &size))
 		return -1;
 	if (lenp)
@@ -578,11 +580,11 @@
 	return 1;
 }
 
-static int
-buffer_getcharbuf(PyBufferObject *self, int idx, const char **pp)
+static Py_ssize_t
+buffer_getcharbuf(PyBufferObject *self, Py_ssize_t idx, const char **pp)
 {
 	void *ptr;
-	int size;
+	Py_ssize_t size;
 	if ( idx != 0 ) {
 		PyErr_SetString(PyExc_SystemError,
 				"accessing non-existent buffer segment");

Modified: python/branches/ssize_t/Objects/classobject.c
==============================================================================
--- python/branches/ssize_t/Objects/classobject.c	(original)
+++ python/branches/ssize_t/Objects/classobject.c	Sun Jan  8 06:48:15 2006
@@ -68,7 +68,7 @@
 			return NULL;
 	}
 	else {
-		int i, n;
+		Py_ssize_t i, n;
 		PyObject *base;
 		if (!PyTuple_Check(bases)) {
 			PyErr_SetString(PyExc_TypeError,
@@ -185,7 +185,7 @@
 static PyObject *
 class_lookup(PyClassObject *cp, PyObject *name, PyClassObject **pclass)
 {
-	int i, n;
+	Py_ssize_t i, n;
 	PyObject *value = PyDict_GetItem(cp->cl_dict, name);
 	if (value != NULL) {
 		*pclass = cp;
@@ -281,7 +281,7 @@
 static char *
 set_bases(PyClassObject *c, PyObject *v)
 {
-	int i, n;
+	Py_ssize_t i, n;
 
 	if (v == NULL || !PyTuple_Check(v))
 		return "__bases__ must be a tuple object";
@@ -483,7 +483,7 @@
 int
 PyClass_IsSubclass(PyObject *class, PyObject *base)
 {
-	int i, n;
+	Py_ssize_t i, n;
 	PyClassObject *cp;
 	if (class == base)
 		return 1;
@@ -1128,7 +1128,7 @@
 }
 
 static PyObject *
-sliceobj_from_intint(int i, int j)
+sliceobj_from_intint(Py_ssize_t i, Py_ssize_t j)
 {
 	PyObject *start, *end, *res;
 
@@ -2434,7 +2434,7 @@
 		Py_INCREF(arg);
 	}
 	else {
-		int argcount = PyTuple_Size(arg);
+		Py_ssize_t argcount = PyTuple_Size(arg);
 		PyObject *newarg = PyTuple_New(argcount + 1);
 		int i;
 		if (newarg == NULL)

Modified: python/branches/ssize_t/Objects/codeobject.c
==============================================================================
--- python/branches/ssize_t/Objects/codeobject.c	(original)
+++ python/branches/ssize_t/Objects/codeobject.c	Sun Jan  8 06:48:15 2006
@@ -28,7 +28,7 @@
 static void
 intern_strings(PyObject *tuple)
 {
-	int i;
+	Py_ssize_t i;
 
 	for (i = PyTuple_GET_SIZE(tuple); --i >= 0; ) {
 		PyObject *v = PyTuple_GET_ITEM(tuple, i);
@@ -48,7 +48,7 @@
 	   PyObject *lnotab)
 {
 	PyCodeObject *co;
-	int i;
+	Py_ssize_t i;
 	/* Check argument types */
 	if (argcount < 0 || nlocals < 0 ||
 	    code == NULL ||
@@ -135,7 +135,7 @@
 {
 	PyObject *newtuple;
 	PyObject *item;
-	int i, len;
+	Py_ssize_t i, len;
 
 	len = PyTuple_GET_SIZE(tup);
 	newtuple = PyTuple_New(len);

Modified: python/branches/ssize_t/Objects/descrobject.c
==============================================================================
--- python/branches/ssize_t/Objects/descrobject.c	(original)
+++ python/branches/ssize_t/Objects/descrobject.c	Sun Jan  8 06:48:15 2006
@@ -209,7 +209,7 @@
 static PyObject *
 methoddescr_call(PyMethodDescrObject *descr, PyObject *args, PyObject *kwds)
 {
-	int argc;
+	Py_ssize_t argc;
 	PyObject *self, *func, *result;
 
 	/* Make sure that the first argument is acceptable as 'self' */
@@ -267,7 +267,7 @@
 static PyObject *
 wrapperdescr_call(PyWrapperDescrObject *descr, PyObject *args, PyObject *kwds)
 {
-	int argc;
+	Py_ssize_t argc;
 	PyObject *self, *func, *result;
 
 	/* Make sure that the first argument is acceptable as 'self' */

Modified: python/branches/ssize_t/Objects/dictobject.c
==============================================================================
--- python/branches/ssize_t/Objects/dictobject.c	(original)
+++ python/branches/ssize_t/Objects/dictobject.c	Sun Jan  8 06:48:15 2006
@@ -217,8 +217,8 @@
 static dictentry *
 lookdict(dictobject *mp, PyObject *key, register long hash)
 {
-	register int i;
-	register unsigned int perturb;
+	register Py_ssize_t i;
+	register size_t perturb;
 	register dictentry *freeslot;
 	register unsigned int mask = mp->ma_mask;
 	dictentry *ep0 = mp->ma_table;
@@ -328,8 +328,8 @@
 static dictentry *
 lookdict_string(dictobject *mp, PyObject *key, register long hash)
 {
-	register int i;
-	register unsigned int perturb;
+	register Py_ssize_t i;
+	register size_t perturb;
 	register dictentry *freeslot;
 	register unsigned int mask = mp->ma_mask;
 	dictentry *ep0 = mp->ma_table;
@@ -692,7 +692,8 @@
 int
 PyDict_Next(PyObject *op, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue)
 {
-	register int i, mask;
+	register Py_ssize_t i;
+	register int mask;
 	register dictentry *ep;
 
 	if (!PyDict_Check(op))
@@ -1109,7 +1110,7 @@
 PyDict_MergeFromSeq2(PyObject *d, PyObject *seq2, int override)
 {
 	PyObject *it;	/* iter(seq2) */
-	int i;		/* index into seq2 of current element */
+	int i;	/* index into seq2 of current element */
 	PyObject *item;	/* seq2[i] */
 	PyObject *fast;	/* item as a 2-tuple or 2-list */
 
@@ -1123,7 +1124,7 @@
 
 	for (i = 0; ; ++i) {
 		PyObject *key, *value;
-		int n;
+		Py_ssize_t n;
 
 		fast = NULL;
 		item = PyIter_Next(it);
@@ -1147,7 +1148,7 @@
 		if (n != 2) {
 			PyErr_Format(PyExc_ValueError,
 				     "dictionary update sequence element #%d "
-				     "has length %d; 2 is required",
+				     "has length %ld; 2 is required",
 				     i, n);
 			goto Fail;
 		}
@@ -2058,7 +2059,7 @@
 static PyObject *
 dictiter_len(dictiterobject *di)
 {
-	int len = 0;
+	long len = 0;
 	if (di->di_dict != NULL && di->di_used == di->di_dict->ma_used)
 		len = di->len;
 	return PyInt_FromLong(len);

Modified: python/branches/ssize_t/Objects/enumobject.c
==============================================================================
--- python/branches/ssize_t/Objects/enumobject.c	(original)
+++ python/branches/ssize_t/Objects/enumobject.c	Sun Jan  8 06:48:15 2006
@@ -241,7 +241,7 @@
 static PyObject *
 reversed_len(reversedobject *ro)
 {
-	int position, seqsize;
+	Py_ssize_t position, seqsize;
 
 	if (ro->seq == NULL)
 		return PyInt_FromLong(0);

Modified: python/branches/ssize_t/Objects/fileobject.c
==============================================================================
--- python/branches/ssize_t/Objects/fileobject.c	(original)
+++ python/branches/ssize_t/Objects/fileobject.c	Sun Jan  8 06:48:15 2006
@@ -137,7 +137,7 @@
 static int
 check_the_mode(char *mode)
 {
-	unsigned int len = strlen(mode);
+	size_t len = strlen(mode);
 
 	switch (len) {
 	case 0:
@@ -1247,7 +1247,7 @@
 
 	if (n < 0 && result != NULL && PyString_Check(result)) {
 		char *s = PyString_AS_STRING(result);
-		int len = PyString_GET_SIZE(result);
+		Py_ssize_t len = PyString_GET_SIZE(result);
 		if (len == 0) {
 			Py_DECREF(result);
 			result = NULL;
@@ -1268,7 +1268,7 @@
 #ifdef Py_USING_UNICODE
 	if (n < 0 && result != NULL && PyUnicode_Check(result)) {
 		Py_UNICODE *s = PyUnicode_AS_UNICODE(result);
-		int len = PyUnicode_GET_SIZE(result);
+		Py_ssize_t len = PyUnicode_GET_SIZE(result);
 		if (len == 0) {
 			Py_DECREF(result);
 			result = NULL;
@@ -1460,8 +1460,8 @@
 	PyObject *list, *line;
 	PyObject *it;	/* iter(seq) */
 	PyObject *result;
-	int i, j, index, len, islist;
-	Py_ssize_t nwritten;
+	int index, islist;
+	Py_ssize_t i, j, nwritten, len;
 
 	assert(seq != NULL);
 	if (f->f_fp == NULL)
@@ -1519,7 +1519,6 @@
 			PyObject *v = PyList_GET_ITEM(list, i);
 			if (!PyString_Check(v)) {
 			    	const char *buffer;
-			    	Py_ssize_t len;
 				if (((f->f_binary &&
 				      PyObject_AsReadBuffer(v,
 					      (const void**)&buffer,
@@ -2029,7 +2028,7 @@
 int
 PyFile_SoftSpace(PyObject *f, int newflag)
 {
-	int oldflag = 0;
+	long oldflag = 0;
 	if (f == NULL) {
 		/* Do nothing */
 	}
@@ -2045,6 +2044,7 @@
 		else {
 			if (PyInt_Check(v))
 				oldflag = PyInt_AsLong(v);
+			assert(oldflag < INT_MAX);
 			Py_DECREF(v);
 		}
 		v = PyInt_FromLong((long)newflag);
@@ -2056,7 +2056,7 @@
 			Py_DECREF(v);
 		}
 	}
-	return oldflag;
+	return (int)oldflag;
 }
 
 /* Interfaces to write objects/strings to file-like objects */

Modified: python/branches/ssize_t/Objects/frameobject.c
==============================================================================
--- python/branches/ssize_t/Objects/frameobject.c	(original)
+++ python/branches/ssize_t/Objects/frameobject.c	Sun Jan  8 06:48:15 2006
@@ -540,7 +540,7 @@
 	PyFrameObject *back = tstate->frame;
 	PyFrameObject *f;
 	PyObject *builtins;
-	int extras, ncells, nfrees, i;
+	Py_ssize_t extras, ncells, nfrees, i;
 
 #ifdef Py_DEBUG
 	if (code == NULL || globals == NULL || !PyDict_Check(globals) ||
@@ -678,10 +678,10 @@
 /* Convert between "fast" version of locals and dictionary version */
 
 static void
-map_to_dict(PyObject *map, int nmap, PyObject *dict, PyObject **values,
-	    int deref)
+map_to_dict(PyObject *map, Py_ssize_t nmap, PyObject *dict, PyObject **values,
+	    Py_ssize_t deref)
 {
-	int j;
+	Py_ssize_t j;
 	for (j = nmap; --j >= 0; ) {
 		PyObject *key = PyTuple_GET_ITEM(map, j);
 		PyObject *value = values[j];
@@ -699,10 +699,10 @@
 }
 
 static void
-dict_to_map(PyObject *map, int nmap, PyObject *dict, PyObject **values,
-	    int deref, int clear)
+dict_to_map(PyObject *map, Py_ssize_t nmap, PyObject *dict, PyObject **values,
+	    Py_ssize_t deref, int clear)
 {
-	int j;
+	Py_ssize_t j;
 	for (j = nmap; --j >= 0; ) {
 		PyObject *key = PyTuple_GET_ITEM(map, j);
 		PyObject *value = PyObject_GetItem(dict, key);
@@ -733,7 +733,7 @@
 	PyObject *locals, *map;
 	PyObject **fast;
 	PyObject *error_type, *error_value, *error_traceback;
-	int j;
+	Py_ssize_t j;
 	if (f == NULL)
 		return;
 	locals = f->f_locals;
@@ -776,7 +776,7 @@
 	PyObject *locals, *map;
 	PyObject **fast;
 	PyObject *error_type, *error_value, *error_traceback;
-	int j;
+	Py_ssize_t j;
 	if (f == NULL)
 		return;
 	locals = f->f_locals;

Modified: python/branches/ssize_t/Objects/funcobject.c
==============================================================================
--- python/branches/ssize_t/Objects/funcobject.c	(original)
+++ python/branches/ssize_t/Objects/funcobject.c	Sun Jan  8 06:48:15 2006
@@ -232,7 +232,7 @@
 func_set_code(PyFunctionObject *op, PyObject *value)
 {
 	PyObject *tmp;
-	int nfree, nclosure;
+	Py_ssize_t nfree, nclosure;
 
 	if (restricted())
 		return -1;
@@ -363,7 +363,7 @@
 	PyObject *defaults = Py_None;
 	PyObject *closure = Py_None;
 	PyFunctionObject *newfunc;
-	int nfree, nclosure;
+	Py_ssize_t nfree, nclosure;
 	static const char *kwlist[] = {"code", "globals", "name",
 				 "argdefs", "closure", 0};
 
@@ -405,7 +405,7 @@
 				    PyString_AS_STRING(code->co_name),
 				    nfree, nclosure);
 	if (nclosure) {
-		int i;
+		Py_ssize_t i;
 		for (i = 0; i < nclosure; i++) {
 			PyObject *o = PyTuple_GET_ITEM(closure, i);
 			if (!PyCell_Check(o)) {
@@ -516,7 +516,7 @@
 	PyObject *result;
 	PyObject *argdefs;
 	PyObject **d, **k;
-	int nk, nd;
+	Py_ssize_t nk, nd;
 
 	argdefs = PyFunction_GET_DEFAULTS(func);
 	if (argdefs != NULL && PyTuple_Check(argdefs)) {

Modified: python/branches/ssize_t/Objects/iterobject.c
==============================================================================
--- python/branches/ssize_t/Objects/iterobject.c	(original)
+++ python/branches/ssize_t/Objects/iterobject.c	Sun Jan  8 06:48:15 2006
@@ -74,7 +74,7 @@
 static PyObject *
 iter_len(seqiterobject *it)
 {
-	int seqsize, len;
+	Py_ssize_t seqsize, len;
 
 	if (it->it_seq) {
 		seqsize = PySequence_Size(it->it_seq);

Modified: python/branches/ssize_t/Objects/listobject.c
==============================================================================
--- python/branches/ssize_t/Objects/listobject.c	(original)
+++ python/branches/ssize_t/Objects/listobject.c	Sun Jan  8 06:48:15 2006
@@ -273,12 +273,13 @@
 static int
 list_print(PyListObject *op, FILE *fp, int flags)
 {
+	int rc;
 	Py_ssize_t i;
 
-	i = Py_ReprEnter((PyObject*)op);
-	if (i != 0) {
-		if (i < 0)
-			return i;
+	rc = Py_ReprEnter((PyObject*)op);
+	if (rc != 0) {
+		if (rc < 0)
+			return rc;
 		fprintf(fp, "[...]");
 		return 0;
 	}
@@ -1051,7 +1052,7 @@
 
 Returns -1 in case of error.
 */
-static int
+static Py_ssize_t
 count_run(PyObject **lo, PyObject **hi, PyObject *compare, int *descending)
 {
 	Py_ssize_t k;
@@ -1387,14 +1388,15 @@
  * merge, and should have na <= nb.  See listsort.txt for more info.
  * Return 0 if successful, -1 if error.
  */
-static int
-merge_lo(MergeState *ms, PyObject **pa, int na, PyObject **pb, int nb)
+static Py_ssize_t
+merge_lo(MergeState *ms, PyObject **pa, Py_ssize_t na,
+                         PyObject **pb, Py_ssize_t nb)
 {
 	Py_ssize_t k;
 	PyObject *compare;
 	PyObject **dest;
 	int result = -1;	/* guilty until proved innocent */
-	int min_gallop = ms->min_gallop;
+	Py_ssize_t min_gallop = ms->min_gallop;
 
 	assert(ms && pa && pb && na > 0 && nb > 0 && pa + na == pb);
 	if (MERGE_GETMEM(ms, na) < 0)
@@ -1518,7 +1520,7 @@
  * merge, and should have na >= nb.  See listsort.txt for more info.
  * Return 0 if successful, -1 if error.
  */
-static int
+static Py_ssize_t
 merge_hi(MergeState *ms, PyObject **pa, Py_ssize_t na, PyObject **pb, Py_ssize_t nb)
 {
 	Py_ssize_t k;
@@ -1655,7 +1657,7 @@
 /* Merge the two runs at stack indices i and i+1.
  * Returns 0 on success, -1 on error.
  */
-static int
+static Py_ssize_t
 merge_at(MergeState *ms, Py_ssize_t i)
 {
 	PyObject **pa, **pb;
@@ -1806,7 +1808,7 @@
 static PyTypeObject sortwrapper_type;
 
 static PyObject *
-sortwrapper_richcompare(sortwrapperobject *a, sortwrapperobject *b, Py_ssize_t op)
+sortwrapper_richcompare(sortwrapperobject *a, sortwrapperobject *b, int op)
 {
 	if (!PyObject_TypeCheck(b, &sortwrapper_type)) {
 		PyErr_SetString(PyExc_TypeError,
@@ -2268,13 +2270,13 @@
 static int
 list_traverse(PyListObject *o, visitproc visit, void *arg)
 {
-	Py_ssize_t i, err;
+	Py_ssize_t i;
 	PyObject *x;
 
 	for (i = o->ob_size; --i >= 0; ) {
 		x = o->ob_item[i];
 		if (x != NULL) {
-			err = visit(x, arg);
+			int err = visit(x, arg);
 			if (err)
 				return err;
 		}
@@ -2598,8 +2600,8 @@
 			if (PySequence_Fast_GET_SIZE(seq) != slicelength) {
 				/* XXX can we use %zd here? */
 				PyErr_Format(PyExc_ValueError,
-            "attempt to assign sequence of size %d to extended slice of size %ld",
-					     (int)PySequence_Fast_GET_SIZE(seq),
+            "attempt to assign sequence of size %ld to extended slice of size %ld",
+					     PySequence_Fast_GET_SIZE(seq),
 					     slicelength);
 				Py_DECREF(seq);
 				return -1;

Modified: python/branches/ssize_t/Objects/methodobject.c
==============================================================================
--- python/branches/ssize_t/Objects/methodobject.c	(original)
+++ python/branches/ssize_t/Objects/methodobject.c	Sun Jan  8 06:48:15 2006
@@ -65,7 +65,7 @@
 	PyCFunctionObject* f = (PyCFunctionObject*)func;
 	PyCFunction meth = PyCFunction_GET_FUNCTION(func);
 	PyObject *self = PyCFunction_GET_SELF(func);
-	int size;
+	long size;
 
 	switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) {
 	case METH_VARARGS:
@@ -81,7 +81,7 @@
 			if (size == 0)
 				return (*meth)(self, NULL);
 			PyErr_Format(PyExc_TypeError,
-			    "%.200s() takes no arguments (%d given)",
+			    "%.200s() takes no arguments (%ld given)",
 			    f->m_ml->ml_name, size);
 			return NULL;
 		}
@@ -92,7 +92,7 @@
 			if (size == 1)
 				return (*meth)(self, PyTuple_GET_ITEM(arg, 0));
 			PyErr_Format(PyExc_TypeError,
-			    "%.200s() takes exactly one argument (%d given)",
+			    "%.200s() takes exactly one argument (%ld given)",
 			    f->m_ml->ml_name, size);
 			return NULL;
 		}

Modified: python/branches/ssize_t/Objects/object.c
==============================================================================
--- python/branches/ssize_t/Objects/object.c	(original)
+++ python/branches/ssize_t/Objects/object.c	Sun Jan  8 06:48:15 2006
@@ -1175,7 +1175,7 @@
 	if (dictoffset == 0)
 		return NULL;
 	if (dictoffset < 0) {
-		int tsize;
+		Py_ssize_t tsize;
 		size_t size;
 
 		tsize = ((PyVarObject *)obj)->ob_size;
@@ -1237,7 +1237,7 @@
 
 	/* Inline _PyType_Lookup */
 	{
-		int i, n;
+		Py_ssize_t i, n;
 		PyObject *mro, *base, *dict;
 
 		/* Look in tp_dict of types in MRO */
@@ -1278,7 +1278,7 @@
 	if (dictoffset != 0) {
 		PyObject *dict;
 		if (dictoffset < 0) {
-			int tsize;
+			Py_ssize_t tsize;
 			size_t size;
 
 			tsize = ((PyVarObject *)obj)->ob_size;
@@ -1432,7 +1432,7 @@
 		res = (*v->ob_type->tp_as_sequence->sq_length)(v);
 	else
 		return 1;
-	return (res > 0) ? 1 : res;
+	return (res > 0) ? 1 : (int)res;
 }
 
 /* equivalent of 'not v'
@@ -1556,7 +1556,7 @@
 		PyErr_Clear();
 	else {
 		/* We have no guarantee that bases is a real tuple */
-		int i, n;
+		Py_ssize_t i, n;
 		n = PySequence_Size(bases); /* This better be right */
 		if (n < 0)
 			PyErr_Clear();
@@ -1992,7 +1992,7 @@
 {
 	PyObject *dict;
 	PyObject *list;
-	int i;
+	Py_ssize_t i;
 
 	dict = PyThreadState_GetDict();
 	if (dict == NULL)
@@ -2020,7 +2020,7 @@
 {
 	PyObject *dict;
 	PyObject *list;
-	int i;
+	Py_ssize_t i;
 
 	dict = PyThreadState_GetDict();
 	if (dict == NULL)

Modified: python/branches/ssize_t/Objects/setobject.c
==============================================================================
--- python/branches/ssize_t/Objects/setobject.c	(original)
+++ python/branches/ssize_t/Objects/setobject.c	Sun Jan  8 06:48:15 2006
@@ -51,8 +51,8 @@
 static setentry *
 set_lookkey(PySetObject *so, PyObject *key, register long hash)
 {
-	register int i;
-	register unsigned int perturb;
+	register Py_ssize_t i;
+	register size_t perturb;
 	register setentry *freeslot;
 	register unsigned int mask = so->mask;
 	setentry *table = so->table;
@@ -129,8 +129,8 @@
 static setentry *
 set_lookkey_string(PySetObject *so, PyObject *key, register long hash)
 {
-	register int i;
-	register unsigned int perturb;
+	register Py_ssize_t i;
+	register size_t perturb;
 	register setentry *freeslot;
 	register unsigned int mask = so->mask;
 	setentry *table = so->table;
@@ -753,7 +753,7 @@
 static PyObject *
 setiter_len(setiterobject *si)
 {
-	int len = 0;
+	long len = 0;
 	if (si->si_set != NULL && si->si_used == si->si_set->used)
 		len = si->len;
 	return PyInt_FromLong(len);
@@ -847,7 +847,7 @@
 		return set_merge(so, other);
 
 	if (PyDict_Check(other)) {
-		PyObject *key, *value;
+		PyObject *value;
 		Py_ssize_t pos = 0;
 		while (PyDict_Next(other, &pos, &key, &value)) {
 			if (set_add_key(so, key) == -1)

Modified: python/branches/ssize_t/Objects/stringobject.c
==============================================================================
--- python/branches/ssize_t/Objects/stringobject.c	(original)
+++ python/branches/ssize_t/Objects/stringobject.c	Sun Jan  8 06:48:15 2006
@@ -666,7 +666,7 @@
 	return NULL;
 }
 
-static int
+static Py_ssize_t
 string_getsize(register PyObject *op)
 {
     	char *s;
@@ -686,7 +686,7 @@
 	return s;
 }
 
-int
+Py_ssize_t
 PyString_Size(register PyObject *op)
 {
 	if (!PyString_Check(op))
@@ -1216,7 +1216,7 @@
 	}
 }
 
-static int
+static Py_ssize_t
 string_buffer_getreadbuf(PyStringObject *self, /*XXX*/int index, const void **ptr)
 {
 	if ( index != 0 ) {
@@ -1237,15 +1237,15 @@
 }
 
 static int
-string_buffer_getsegcount(PyStringObject *self, int *lenp)
+string_buffer_getsegcount(PyStringObject *self, Py_ssize_t *lenp)
 {
 	if ( lenp )
 		*lenp = self->ob_size;
 	return 1;
 }
 
-static int
-string_buffer_getcharbuf(PyStringObject *self, int index, const char **ptr)
+static Py_ssize_t
+string_buffer_getcharbuf(PyStringObject *self, Py_ssize_t index, const char **ptr)
 {
 	if ( index != 0 ) {
 		PyErr_SetString(PyExc_SystemError,
@@ -2894,11 +2894,11 @@
 static PyObject *
 string_center(PyStringObject *self, PyObject *args)
 {
-    int marg, left;
-    int width;
+    Py_ssize_t marg, left;
+    long width;
     char fillchar = ' ';
 
-    if (!PyArg_ParseTuple(args, "i|c:center", &width, &fillchar))
+    if (!PyArg_ParseTuple(args, "l|c:center", &width, &fillchar))
         return NULL;
 
     if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) {
@@ -2921,12 +2921,12 @@
 static PyObject *
 string_zfill(PyStringObject *self, PyObject *args)
 {
-    int fill;
+    long fill;
     PyObject *s;
     char *p;
 
     int width;
-    if (!PyArg_ParseTuple(args, "i:zfill", &width))
+    if (!PyArg_ParseTuple(args, "l:zfill", &width))
         return NULL;
 
     if (PyString_GET_SIZE(self) >= width) {
@@ -3228,7 +3228,7 @@
         goto onError;
 
     for (i = j = 0; i < len; ) {
-	int eol;
+	Py_ssize_t eol;
 
 	/* Find a line and append it */
 	while (i < len && data[i] != '\n' && data[i] != '\r')
@@ -4394,7 +4394,7 @@
 {
 	PyObject *keys;
 	PyStringObject *s;
-	int i, n;
+	Py_ssize_t i, n;
 
 	if (interned == NULL || !PyDict_Check(interned))
 		return;

Modified: python/branches/ssize_t/Objects/structseq.c
==============================================================================
--- python/branches/ssize_t/Objects/structseq.c	(original)
+++ python/branches/ssize_t/Objects/structseq.c	Sun Jan  8 06:48:15 2006
@@ -40,7 +40,7 @@
 static void
 structseq_dealloc(PyStructSequence *obj)
 {
-	int i, size;
+	Py_ssize_t i, size;
 
 	size = REAL_SIZE(obj);
 	for (i = 0; i < size; ++i) {
@@ -70,7 +70,7 @@
 structseq_slice(PyStructSequence *obj, Py_ssize_t low, Py_ssize_t high)
 {
 	PyTupleObject *np;
-	int i;
+	Py_ssize_t i;
 
 	if (low < 0)
 		low = 0;
@@ -96,7 +96,7 @@
 	PyObject *dict = NULL;
 	PyObject *ob;
 	PyStructSequence *res = NULL;
-	int len, min_len, max_len, i, n_unnamed_fields;
+	Py_ssize_t len, min_len, max_len, i, n_unnamed_fields;
 	static const char *kwlist[] = {"sequence", "dict", 0};
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:structseq", 
@@ -125,7 +125,7 @@
 	if (min_len != max_len) {
 		if (len < min_len) {
 			PyErr_Format(PyExc_TypeError, 
-	       "%.500s() takes an at least %d-sequence (%d-sequence given)",
+	       "%.500s() takes an at least %ld-sequence (%ld-sequence given)",
 				     type->tp_name, min_len, len);
 			Py_DECREF(arg);
 			return NULL;
@@ -133,7 +133,7 @@
 
 		if (len > max_len) {
 			PyErr_Format(PyExc_TypeError, 
-	       "%.500s() takes an at most %d-sequence (%d-sequence given)",
+	       "%.500s() takes an at most %ld-sequence (%ld-sequence given)",
 				     type->tp_name, max_len, len);
 			Py_DECREF(arg);
 			return NULL;
@@ -142,7 +142,7 @@
 	else {
 		if (len != min_len) {
 			PyErr_Format(PyExc_TypeError, 
-	       "%.500s() takes a %d-sequence (%d-sequence given)",
+	       "%.500s() takes a %ld-sequence (%ld-sequence given)",
 				     type->tp_name, min_len, len);
 			Py_DECREF(arg);
 			return NULL;

Modified: python/branches/ssize_t/Objects/tupleobject.c
==============================================================================
--- python/branches/ssize_t/Objects/tupleobject.c	(original)
+++ python/branches/ssize_t/Objects/tupleobject.c	Sun Jan  8 06:48:15 2006
@@ -27,7 +27,7 @@
 PyTuple_New(register Py_ssize_t size)
 {
 	register PyTupleObject *op;
-	int i;
+	Py_ssize_t i;
 	if (size < 0) {
 		PyErr_BadInternalCall();
 		return NULL;
@@ -57,7 +57,7 @@
 	else
 #endif
 	{
-		int nbytes = size * sizeof(PyObject *);
+		Py_ssize_t nbytes = size * sizeof(PyObject *);
 		/* Check for overflow */
 		if (nbytes / sizeof(PyObject *) != (size_t)size ||
 		    (nbytes += sizeof(PyTupleObject) - sizeof(PyObject *))
@@ -131,9 +131,9 @@
 }
 
 PyObject *
-PyTuple_Pack(int n, ...)
+PyTuple_Pack(Py_ssize_t n, ...)
 {
-	int i;
+	Py_ssize_t i;
 	PyObject *o;
 	PyObject *result;
 	PyObject **items;
@@ -159,8 +159,8 @@
 static void
 tupledealloc(register PyTupleObject *op)
 {
-	register int i;
-	register int len =  op->ob_size;
+	register Py_ssize_t i;
+	register Py_ssize_t len =  op->ob_size;
 	PyObject_GC_UnTrack(op);
 	Py_TRASHCAN_SAFE_BEGIN(op)
 	if (len > 0) {
@@ -187,7 +187,7 @@
 static int
 tupleprint(PyTupleObject *op, FILE *fp, int flags)
 {
-	int i;
+	Py_ssize_t i;
 	fprintf(fp, "(");
 	for (i = 0; i < op->ob_size; i++) {
 		if (i > 0)
@@ -204,7 +204,7 @@
 static PyObject *
 tuplerepr(PyTupleObject *v)
 {
-	int i, n;
+	Py_ssize_t i, n;
 	PyObject *s, *temp;
 	PyObject *pieces, *result = NULL;
 
@@ -268,7 +268,7 @@
 tuplehash(PyTupleObject *v)
 {
 	register long x, y;
-	register int len = v->ob_size;
+	register Py_ssize_t len = v->ob_size;
 	register PyObject **p;
 	long mult = 1000003L;
 	x = 0x345678L;
@@ -295,7 +295,8 @@
 static int
 tuplecontains(PyTupleObject *a, PyObject *el)
 {
-	int i, cmp;
+	Py_ssize_t i;
+	int cmp;
 
 	for (i = 0, cmp = 0 ; cmp == 0 && i < a->ob_size; ++i)
 		cmp = PyObject_RichCompareBool(el, PyTuple_GET_ITEM(a, i),
@@ -320,8 +321,8 @@
 {
 	register PyTupleObject *np;
 	PyObject **src, **dest;
-	register int i;
-	int len;
+	register Py_ssize_t i;
+	Py_ssize_t len;
 	if (ilow < 0)
 		ilow = 0;
 	if (ihigh > a->ob_size)
@@ -359,8 +360,8 @@
 static PyObject *
 tupleconcat(register PyTupleObject *a, register PyObject *bb)
 {
-	register int size;
-	register int i;
+	register Py_ssize_t size;
+	register Py_ssize_t i;
 	PyObject **src, **dest;
 	PyTupleObject *np;
 	if (!PyTuple_Check(bb)) {
@@ -398,8 +399,8 @@
 static PyObject *
 tuplerepeat(PyTupleObject *a, Py_ssize_t n)
 {
-	int i, j;
-	int size;
+	Py_ssize_t i, j;
+	Py_ssize_t size;
 	PyTupleObject *np;
 	PyObject **p, **items;
 	if (n < 0)
@@ -435,13 +436,13 @@
 static int
 tupletraverse(PyTupleObject *o, visitproc visit, void *arg)
 {
-	int i, err;
+	Py_ssize_t i;
 	PyObject *x;
 
 	for (i = o->ob_size; --i >= 0; ) {
 		x = o->ob_item[i];
 		if (x != NULL) {
-			err = visit(x, arg);
+			int err = visit(x, arg);
 			if (err)
 				return err;
 		}
@@ -453,8 +454,8 @@
 tuplerichcompare(PyObject *v, PyObject *w, int op)
 {
 	PyTupleObject *vt, *wt;
-	int i;
-	int vlen, wlen;
+	Py_ssize_t i;
+	Py_ssize_t vlen, wlen;
 
 	if (!PyTuple_Check(v) || !PyTuple_Check(w)) {
 		Py_INCREF(Py_NotImplemented);
@@ -546,7 +547,7 @@
 tuple_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
 	PyObject *tmp, *new, *item;
-	int i, n;
+	Py_ssize_t i, n;
 
 	assert(PyType_IsSubtype(type, &PyTuple_Type));
 	tmp = tuple_new(&PyTuple_Type, args, kwds);
@@ -702,12 +703,12 @@
    known to some other part of the code. */
 
 int
-_PyTuple_Resize(PyObject **pv, int newsize)
+_PyTuple_Resize(PyObject **pv, Py_ssize_t newsize)
 {
 	register PyTupleObject *v;
 	register PyTupleObject *sv;
-	int i;
-	int oldsize;
+	Py_ssize_t i;
+	Py_ssize_t oldsize;
 
 	v = (PyTupleObject *) *pv;
 	if (v == NULL || v->ob_type != &PyTuple_Type ||
@@ -849,7 +850,7 @@
 static PyObject *
 tupleiter_len(tupleiterobject *it)
 {
-	int len = 0;
+	long len = 0;
 	if (it->it_seq)
 		len = PyTuple_GET_SIZE(it->it_seq) - it->it_index;
 	return PyInt_FromLong(len);

Modified: python/branches/ssize_t/Objects/typeobject.c
==============================================================================
--- python/branches/ssize_t/Objects/typeobject.c	(original)
+++ python/branches/ssize_t/Objects/typeobject.c	Sun Jan  8 06:48:15 2006
@@ -145,7 +145,7 @@
 {
 	PyTypeObject *subclass;
 	PyObject *ref, *subclasses, *old_mro;
-	int i, n;
+	Py_ssize_t i, n;
 
 	subclasses = type->tp_subclasses;
 	if (subclasses == NULL)
@@ -184,7 +184,8 @@
 static int
 type_set_bases(PyTypeObject *type, PyObject *value, void *context)
 {
-	int i, r = 0;
+	Py_ssize_t i;
+	int r = 0;
 	PyObject *ob, *temp;
 	PyTypeObject *new_base, *old_base;
 	PyObject *old_bases, *old_mro;
@@ -483,7 +484,7 @@
 static int
 traverse_slots(PyTypeObject *type, PyObject *self, visitproc visit, void *arg)
 {
-	int i, n;
+	Py_ssize_t i, n;
 	PyMemberDef *mp;
 
 	n = type->ob_size;
@@ -548,7 +549,7 @@
 static void
 clear_slots(PyTypeObject *type, PyObject *self)
 {
-	int i, n;
+	Py_ssize_t i, n;
 	PyMemberDef *mp;
 
 	n = type->ob_size;
@@ -825,7 +826,7 @@
 	if (mro != NULL) {
 		/* Deal with multiple inheritance without recursion
 		   by walking the MRO tuple */
-		int i, n;
+		Py_ssize_t i, n;
 		assert(PyTuple_Check(mro));
 		n = PyTuple_GET_SIZE(mro);
 		for (i = 0; i < n; i++) {
@@ -970,7 +971,7 @@
 fill_classic_mro(PyObject *mro, PyObject *cls)
 {
 	PyObject *bases, *base;
-	int i, n;
+	Py_ssize_t i, n;
 
 	assert(PyList_Check(mro));
 	assert(PyClass_Check(cls));
@@ -1037,7 +1038,7 @@
 
 static int
 tail_contains(PyObject *list, int whence, PyObject *o) {
-	int j, size;
+	Py_ssize_t j, size;
 	size = PyList_GET_SIZE(list);
 
 	for (j = whence+1; j < size; j++) {
@@ -1068,7 +1069,7 @@
 static int
 check_duplicates(PyObject *list)
 {
-	int i, j, n;
+	Py_ssize_t i, j, n;
 	/* Let's use a quadratic time algorithm,
 	   assuming that the bases lists is short.
 	*/
@@ -1136,9 +1137,9 @@
 
 static int
 pmerge(PyObject *acc, PyObject* to_merge) {
-	int i, j, to_merge_size;
+	Py_ssize_t i, j, to_merge_size, empty_cnt;
 	int *remain;
-	int ok, empty_cnt;
+	int ok;
 
 	to_merge_size = PyList_GET_SIZE(to_merge);
 
@@ -1206,7 +1207,8 @@
 static PyObject *
 mro_implementation(PyTypeObject *type)
 {
-	int i, n, ok;
+	Py_ssize_t i, n;
+	int ok;
 	PyObject *bases, *result;
 	PyObject *to_merge, *bases_aslist;
 
@@ -1309,7 +1311,7 @@
 	if (tuple == NULL)
 		return -1;
 	if (checkit) {
-		int i, len;
+		Py_ssize_t i, len;
 		PyObject *cls;
 		PyTypeObject *solid;
 
@@ -1350,7 +1352,7 @@
 static PyTypeObject *
 best_base(PyObject *bases)
 {
-	int i, n;
+	Py_ssize_t i, n;
 	PyTypeObject *base, *winner, *candidate, *base_i;
 	PyObject *base_proto;
 
@@ -1532,7 +1534,7 @@
 valid_identifier(PyObject *s)
 {
 	unsigned char *p;
-	int i, n;
+	Py_ssize_t i, n;
 
 	if (!PyString_Check(s)) {
 		PyErr_SetString(PyExc_TypeError,
@@ -1596,7 +1598,7 @@
 	PyTypeObject *type, *base, *tmptype, *winner;
 	PyHeapTypeObject *et;
 	PyMemberDef *mp;
-	int i, nbases, nslots, slotoffset, add_dict, add_weak;
+	Py_ssize_t i, nbases, nslots, slotoffset, add_dict, add_weak;
 	int j, may_add_dict, may_add_weak;
 
 	assert(args != NULL && PyTuple_Check(args));
@@ -1604,8 +1606,8 @@
 
 	/* Special case: type(x) should return x->ob_type */
 	{
-		const int nargs = PyTuple_GET_SIZE(args);
-		const int nkwds = kwds == NULL ? 0 : PyDict_Size(kwds);
+		const Py_ssize_t nargs = PyTuple_GET_SIZE(args);
+		const Py_ssize_t nkwds = kwds == NULL ? 0 : PyDict_Size(kwds);
 
 		if (PyType_CheckExact(metatype) && nargs == 1 && nkwds == 0) {
 			PyObject *x = PyTuple_GET_ITEM(args, 0);
@@ -1999,7 +2001,7 @@
 PyObject *
 _PyType_Lookup(PyTypeObject *type, PyObject *name)
 {
-	int i, n;
+	Py_ssize_t i, n;
 	PyObject *mro, *res, *base, *dict;
 
 	/* Look in tp_dict of types in MRO */
@@ -2154,7 +2156,7 @@
 type_subclasses(PyTypeObject *type, PyObject *args_ignored)
 {
 	PyObject *list, *raw, *ref;
-	int i, n;
+	Py_ssize_t i, n;
 
 	list = PyList_New(0);
 	if (list == NULL)
@@ -2587,7 +2589,7 @@
 	PyObject *getstate = NULL, *state = NULL, *names = NULL;
 	PyObject *slots = NULL, *listitems = NULL, *dictitems = NULL;
 	PyObject *copy_reg = NULL, *newobj = NULL, *res = NULL;
-	int i, n;
+	Py_ssize_t i, n;
 
 	cls = PyObject_GetAttrString(obj, "__class__");
 	if (cls == NULL)
@@ -3155,7 +3157,7 @@
 {
 	PyObject *dict, *bases;
 	PyTypeObject *base;
-	int i, n;
+	Py_ssize_t i, n;
 
 	if (type->tp_flags & Py_TPFLAGS_READY) {
 		assert(type->tp_dict != NULL);
@@ -3340,7 +3342,7 @@
 static void
 remove_subclass(PyTypeObject *base, PyTypeObject *type)
 {
-	int i;
+	Py_ssize_t i;
 	PyObject *list, *ref;
 
 	list = base->tp_subclasses;
@@ -3547,7 +3549,7 @@
 	if (i < 0) {
 		PySequenceMethods *sq = self->ob_type->tp_as_sequence;
 		if (sq && sq->sq_length) {
-			int n = (*sq->sq_length)(self);
+			Py_ssize_t n = (*sq->sq_length)(self);
 			if (n < 0)
 				return -1;
 			i += n;
@@ -3561,7 +3563,7 @@
 {
 	ssizeargfunc func = (ssizeargfunc)wrapped;
 	PyObject *arg;
-	int i;
+	Py_ssize_t i;
 
 	if (PyTuple_GET_SIZE(args) == 1) {
 		arg = PyTuple_GET_ITEM(args, 0);
@@ -4433,7 +4435,7 @@
 {
 	PyObject *func, *args, *res;
 	static PyObject *cmp_str;
-	int c;
+	Py_ssize_t c;
 
 	func = lookup_method(self, "__cmp__", &cmp_str);
 	if (func == NULL) {
@@ -4811,7 +4813,7 @@
 	static PyObject *new_str;
 	PyObject *func;
 	PyObject *newargs, *x;
-	int i, n;
+	Py_ssize_t i, n;
 
 	if (new_str == NULL) {
 		new_str = PyString_InternFromString("__new__");
@@ -5157,9 +5159,10 @@
    proper indirection pointer (as_buffer, etc.); it returns NULL if the
    indirection pointer is NULL. */
 static void **
-slotptr(PyTypeObject *type, int offset)
+slotptr(PyTypeObject *type, int ioffset)
 {
 	char *ptr;
+	long offset = ioffset;
 
 	/* Note: this depends on the order of the members of PyHeapTypeObject! */
 	assert(offset >= 0);
@@ -5424,7 +5427,7 @@
 {
 	PyTypeObject *subclass;
 	PyObject *ref, *subclasses, *dict;
-	int i, n;
+	Py_ssize_t i, n;
 
 	subclasses = type->tp_subclasses;
 	if (subclasses == NULL)
@@ -5577,7 +5580,7 @@
 		PyObject *mro, *res, *tmp, *dict;
 		PyTypeObject *starttype;
 		descrgetfunc f;
-		int i, n;
+		Py_ssize_t i, n;
 
 		starttype = su->obj_type;
 		mro = starttype->tp_mro;

Modified: python/branches/ssize_t/Objects/weakrefobject.c
==============================================================================
--- python/branches/ssize_t/Objects/weakrefobject.c	(original)
+++ python/branches/ssize_t/Objects/weakrefobject.c	Sun Jan  8 06:48:15 2006
@@ -886,7 +886,7 @@
     }
     if (*list != NULL) {
         PyWeakReference *current = *list;
-        int count = _PyWeakref_GetWeakrefCount(current);
+        Py_ssize_t count = _PyWeakref_GetWeakrefCount(current);
         int restore_error = PyErr_Occurred() ? 1 : 0;
         PyObject *err_type, *err_value, *err_tb;
 
@@ -904,7 +904,7 @@
         }
         else {
             PyObject *tuple = PyTuple_New(count * 2);
-            int i = 0;
+            Py_ssize_t i = 0;
 
             for (i = 0; i < count; ++i) {
                 PyWeakReference *next = current->wr_next;
@@ -920,8 +920,8 @@
                 PyObject *callback = PyTuple_GET_ITEM(tuple, i * 2 + 1);
 
                 if (callback != NULL) {
-                    PyObject *current = PyTuple_GET_ITEM(tuple, i * 2);
-                    handle_callback((PyWeakReference *)current, callback);
+                    PyObject *item = PyTuple_GET_ITEM(tuple, i * 2);
+                    handle_callback((PyWeakReference *)item, callback);
                 }
             }
             Py_DECREF(tuple);

Modified: python/branches/ssize_t/Python/pystrtod.c
==============================================================================
--- python/branches/ssize_t/Python/pystrtod.c	(original)
+++ python/branches/ssize_t/Python/pystrtod.c	Sun Jan  8 06:48:15 2006
@@ -159,7 +159,7 @@
  **/
 char *
 PyOS_ascii_formatd(char       *buffer, 
-		   int         buf_len, 
+		   size_t      buf_len, 
 		   const char *format, 
 		   double      d)
 {


More information about the Python-checkins mailing list