[Python-checkins] commit of r41784 - in python/branches/ssize_t: Include/abstract.h Include/unicodeobject.h Modules/_codecsmodule.c Modules/cStringIO.c Modules/stropmodule.c Objects/abstract.c Objects/complexobject.c Objects/fileobject.c Objects/floatobject.c Objects/frameobject.c Objects/unicodeobject.c Python/bltinmodule.c

martin.v.loewis python-checkins at python.org
Wed Dec 21 00:59:06 CET 2005


Author: martin.v.loewis
Date: Wed Dec 21 00:59:03 2005
New Revision: 41784

Modified:
   python/branches/ssize_t/Include/abstract.h
   python/branches/ssize_t/Include/unicodeobject.h
   python/branches/ssize_t/Modules/_codecsmodule.c
   python/branches/ssize_t/Modules/cStringIO.c
   python/branches/ssize_t/Modules/stropmodule.c
   python/branches/ssize_t/Objects/abstract.c
   python/branches/ssize_t/Objects/complexobject.c
   python/branches/ssize_t/Objects/fileobject.c
   python/branches/ssize_t/Objects/floatobject.c
   python/branches/ssize_t/Objects/frameobject.c
   python/branches/ssize_t/Objects/unicodeobject.c
   python/branches/ssize_t/Python/bltinmodule.c
Log:
Add Py_ssize_t into more places.


Modified: python/branches/ssize_t/Include/abstract.h
==============================================================================
--- python/branches/ssize_t/Include/abstract.h	(original)
+++ python/branches/ssize_t/Include/abstract.h	Wed Dec 21 00:59:03 2005
@@ -472,7 +472,7 @@
 
      PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj,
 					  const char **buffer,
-					  int *buffer_len);
+					  Py_ssize_t *buffer_len);
 
        /* 
 	  Takes an arbitrary object which must support the (character,
@@ -497,7 +497,7 @@
 
      PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj,
 					  const void **buffer,
-					  int *buffer_len);
+					  Py_ssize_t *buffer_len);
 
        /* 
 	  Same as PyObject_AsCharBuffer() except that this API expects

Modified: python/branches/ssize_t/Include/unicodeobject.h
==============================================================================
--- python/branches/ssize_t/Include/unicodeobject.h	(original)
+++ python/branches/ssize_t/Include/unicodeobject.h	Wed Dec 21 00:59:03 2005
@@ -1056,11 +1056,11 @@
 /* Return 1 if substr matches str[start:end] at the given tail end, 0
    otherwise. */
 
-PyAPI_FUNC(int) PyUnicode_Tailmatch(
+PyAPI_FUNC(Py_ssize_t) PyUnicode_Tailmatch(
     PyObject *str,		/* String */ 
     PyObject *substr,		/* Prefix or Suffix string */
-    int start,			/* Start index */
-    int end,			/* Stop index */
+    Py_ssize_t start,		/* Start index */
+    Py_ssize_t end,		/* Stop index */
     int direction		/* Tail end: -1 prefix, +1 suffix */
     );
 
@@ -1068,21 +1068,21 @@
    given search direction or -1 if not found. -2 is returned in case
    an error occurred and an exception is set. */
 
-PyAPI_FUNC(int) PyUnicode_Find(
+PyAPI_FUNC(Py_ssize_t) PyUnicode_Find(
     PyObject *str,		/* String */ 
     PyObject *substr,		/* Substring to find */
-    int start,			/* Start index */
-    int end,			/* Stop index */
+    Py_ssize_t start,		/* Start index */
+    Py_ssize_t end,		/* Stop index */
     int direction		/* Find direction: +1 forward, -1 backward */
     );
 
 /* Count the number of occurrences of substr in str[start:end]. */
 
-PyAPI_FUNC(int) PyUnicode_Count(
+PyAPI_FUNC(Py_ssize_t) PyUnicode_Count(
     PyObject *str,		/* String */ 
     PyObject *substr,		/* Substring to count */
-    int start,			/* Start index */
-    int end			/* Stop index */
+    Py_ssize_t start,		/* Start index */
+    Py_ssize_t end		/* Stop index */
     );
 
 /* Replace at most maxcount occurrences of substr in str with replstr

Modified: python/branches/ssize_t/Modules/_codecsmodule.c
==============================================================================
--- python/branches/ssize_t/Modules/_codecsmodule.c	(original)
+++ python/branches/ssize_t/Modules/_codecsmodule.c	Wed Dec 21 00:59:03 2005
@@ -242,7 +242,7 @@
     PyObject *obj;
     const char *errors = NULL;
     const char *data;
-    int size;
+    Py_ssize_t size;
 
     if (!PyArg_ParseTuple(args, "O|z:unicode_internal_decode",
 			  &obj, &errors))
@@ -572,7 +572,7 @@
     PyObject *obj;
     const char *errors = NULL;
     const char *data;
-    int size;
+    Py_ssize_t size;
 
     if (!PyArg_ParseTuple(args, "O|z:unicode_internal_encode",
 			  &obj, &errors))

Modified: python/branches/ssize_t/Modules/cStringIO.c
==============================================================================
--- python/branches/ssize_t/Modules/cStringIO.c	(original)
+++ python/branches/ssize_t/Modules/cStringIO.c	Wed Dec 21 00:59:03 2005
@@ -440,7 +440,7 @@
 	if (it == NULL)
 		return NULL;
 	while ((s = PyIter_Next(it)) != NULL) {
-		int n;
+		Py_ssize_t n;
 		char *c;
 		if (PyString_AsStringAndSize(s, &c, &n) == -1) {
 			Py_DECREF(it);
@@ -656,7 +656,7 @@
 newIobject(PyObject *s) {
   Iobject *self;
   char *buf;
-  int size;
+  Py_ssize_t size;
 
   if (PyObject_AsReadBuffer(s, (const void **)&buf, &size)) {
       PyErr_Format(PyExc_TypeError, "expected read buffer, %.200s found",

Modified: python/branches/ssize_t/Modules/stropmodule.c
==============================================================================
--- python/branches/ssize_t/Modules/stropmodule.c	(original)
+++ python/branches/ssize_t/Modules/stropmodule.c	Wed Dec 21 00:59:03 2005
@@ -364,7 +364,7 @@
 do_strip(PyObject *args, int striptype)
 {
 	char *s;
-	int len, i, j;
+	Py_ssize_t len, i, j;
 
 
 	if (PyString_AsStringAndSize(args, &s, &len))
@@ -443,7 +443,7 @@
 strop_lower(PyObject *self, PyObject *args)
 {
 	char *s, *s_new;
-	int i, n;
+	Py_ssize_t i, n;
 	PyObject *new;
 	int changed;
 
@@ -482,7 +482,7 @@
 strop_upper(PyObject *self, PyObject *args)
 {
 	char *s, *s_new;
-	int i, n;
+	Py_ssize_t i, n;
 	PyObject *new;
 	int changed;
 
@@ -522,7 +522,7 @@
 strop_capitalize(PyObject *self, PyObject *args)
 {
 	char *s, *s_new;
-	int i, n;
+	Py_ssize_t i, n;
 	PyObject *new;
 	int changed;
 
@@ -688,7 +688,7 @@
 strop_swapcase(PyObject *self, PyObject *args)
 {
 	char *s, *s_new;
-	int i, n;
+	Py_ssize_t i, n;
 	PyObject *new;
 	int changed;
 

Modified: python/branches/ssize_t/Objects/abstract.c
==============================================================================
--- python/branches/ssize_t/Objects/abstract.c	(original)
+++ python/branches/ssize_t/Objects/abstract.c	Wed Dec 21 00:59:03 2005
@@ -218,11 +218,11 @@
 
 int PyObject_AsCharBuffer(PyObject *obj,
 			  const char **buffer,
-			  int *buffer_len)
+			  Py_ssize_t *buffer_len)
 {
 	PyBufferProcs *pb;
 	const char *pp;
-	int len;
+	Py_ssize_t len;
 
 	if (obj == NULL || buffer == NULL || buffer_len == NULL) {
 		null_error();
@@ -264,11 +264,11 @@
 
 int PyObject_AsReadBuffer(PyObject *obj,
 			  const 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();
@@ -946,7 +946,7 @@
 
 /* Add a check for embedded NULL-bytes in the argument. */
 static PyObject *
-int_from_string(const char *s, int len)
+int_from_string(const char *s, Py_ssize_t len)
 {
 	char *end;
 	PyObject *x;
@@ -968,7 +968,7 @@
 {
 	PyNumberMethods *m;
 	const char *buffer;
-	int buffer_len;
+	Py_ssize_t buffer_len;
 
 	if (o == NULL)
 		return null_error();
@@ -1009,7 +1009,7 @@
 
 /* Add a check for embedded NULL-bytes in the argument. */
 static PyObject *
-long_from_string(const char *s, int len)
+long_from_string(const char *s, Py_ssize_t len)
 {
 	char *end;
 	PyObject *x;
@@ -1031,7 +1031,7 @@
 {
 	PyNumberMethods *m;
 	const char *buffer;
-	int buffer_len;
+	Py_ssize_t buffer_len;
 
 	if (o == NULL)
 		return null_error();

Modified: python/branches/ssize_t/Objects/complexobject.c
==============================================================================
--- python/branches/ssize_t/Objects/complexobject.c	(original)
+++ python/branches/ssize_t/Objects/complexobject.c	Wed Dec 21 00:59:03 2005
@@ -680,7 +680,7 @@
 #ifdef Py_USING_UNICODE
 	char s_buffer[256];
 #endif
-	int len;
+	Py_ssize_t len;
 
 	if (PyString_Check(v)) {
 		s = PyString_AS_STRING(v);
@@ -699,7 +699,7 @@
 					    NULL))
 			return NULL;
 		s = s_buffer;
-		len = (int)strlen(s);
+		len = strlen(s);
 	}
 #endif
 	else if (PyObject_AsCharBuffer(v, &s, &len)) {

Modified: python/branches/ssize_t/Objects/fileobject.c
==============================================================================
--- python/branches/ssize_t/Objects/fileobject.c	(original)
+++ python/branches/ssize_t/Objects/fileobject.c	Wed Dec 21 00:59:03 2005
@@ -1519,7 +1519,7 @@
 			PyObject *v = PyList_GET_ITEM(list, i);
 			if (!PyString_Check(v)) {
 			    	const char *buffer;
-			    	int len;
+			    	Py_ssize_t len;
 				if (((f->f_binary &&
 				      PyObject_AsReadBuffer(v,
 					      (const void**)&buffer,

Modified: python/branches/ssize_t/Objects/floatobject.c
==============================================================================
--- python/branches/ssize_t/Objects/floatobject.c	(original)
+++ python/branches/ssize_t/Objects/floatobject.c	Wed Dec 21 00:59:03 2005
@@ -87,7 +87,7 @@
 #ifdef Py_USING_UNICODE
 	char s_buffer[256]; /* for objects convertible to a char buffer */
 #endif
-	int len;
+	Py_ssize_t len;
 
 	if (pend)
 		*pend = NULL;
@@ -108,7 +108,7 @@
 					    NULL))
 			return NULL;
 		s = s_buffer;
-		len = (int)strlen(s);
+		len = strlen(s);
 	}
 #endif
 	else if (PyObject_AsCharBuffer(v, &s, &len)) {

Modified: python/branches/ssize_t/Objects/frameobject.c
==============================================================================
--- python/branches/ssize_t/Objects/frameobject.c	(original)
+++ python/branches/ssize_t/Objects/frameobject.c	Wed Dec 21 00:59:03 2005
@@ -71,9 +71,9 @@
 	int new_lasti = 0;		/* The new value of f_lasti */
 	int new_iblock = 0;		/* The new value of f_iblock */
 	char *code = NULL;		/* The bytecode for the frame... */
-	int code_len = 0;		/* ...and its length */
+	Py_ssize_t code_len = 0;	/* ...and its length */
 	char *lnotab = NULL;		/* Iterating over co_lnotab */
-	int lnotab_len = 0;		/* (ditto) */
+	Py_ssize_t lnotab_len = 0;	/* (ditto) */
 	int offset = 0;			/* (ditto) */
 	int line = 0;			/* (ditto) */
 	int addr = 0;			/* (ditto) */

Modified: python/branches/ssize_t/Objects/unicodeobject.c
==============================================================================
--- python/branches/ssize_t/Objects/unicodeobject.c	(original)
+++ python/branches/ssize_t/Objects/unicodeobject.c	Wed Dec 21 00:59:03 2005
@@ -457,7 +457,7 @@
 				      const char *errors)
 {
     const char *s = NULL;
-    int len;
+    Py_ssize_t len;
     PyObject *v;
 
     if (obj == NULL) {
@@ -3829,12 +3829,12 @@
     return count;
 }
 
-int PyUnicode_Count(PyObject *str,
+Py_ssize_t PyUnicode_Count(PyObject *str,
 		    PyObject *substr,
-		    int start,
-		    int end)
+		    Py_ssize_t start,
+		    Py_ssize_t end)
 {
-    int result;
+    Py_ssize_t result;
 
     str = PyUnicode_FromObject(str);
     if (str == NULL)
@@ -3855,10 +3855,10 @@
 }
 
 static
-int findstring(PyUnicodeObject *self,
+Py_ssize_t findstring(PyUnicodeObject *self,
 	       PyUnicodeObject *substring,
-	       int start,
-	       int end,
+	       Py_ssize_t start,
+	       Py_ssize_t end,
 	       int direction)
 {
     if (start < 0)
@@ -3891,13 +3891,13 @@
     return -1;
 }
 
-int PyUnicode_Find(PyObject *str,
+Py_ssize_t PyUnicode_Find(PyObject *str,
 		   PyObject *substr,
-		   int start,
-		   int end,
+		   Py_ssize_t start,
+		   Py_ssize_t end,
 		   int direction)
 {
-    int result;
+    Py_ssize_t result;
 
     str = PyUnicode_FromObject(str);
     if (str == NULL)
@@ -3917,10 +3917,10 @@
 }
 
 static
-int tailmatch(PyUnicodeObject *self,
+Py_ssize_t tailmatch(PyUnicodeObject *self,
 	      PyUnicodeObject *substring,
-	      int start,
-	      int end,
+	      Py_ssize_t start,
+	      Py_ssize_t end,
 	      int direction)
 {
     if (start < 0)
@@ -3953,13 +3953,13 @@
     return 0;
 }
 
-int PyUnicode_Tailmatch(PyObject *str,
+Py_ssize_t PyUnicode_Tailmatch(PyObject *str,
 			PyObject *substr,
-			int start,
-			int end,
+			Py_ssize_t start,
+			Py_ssize_t end,
 			int direction)
 {
-    int result;
+    Py_ssize_t result;
 
     str = PyUnicode_FromObject(str);
     if (str == NULL)
@@ -5089,8 +5089,8 @@
 unicode_count(PyUnicodeObject *self, PyObject *args)
 {
     PyUnicodeObject *substring;
-    int start = 0;
-    int end = INT_MAX;
+    Py_ssize_t start = 0;
+    Py_ssize_t end = INT_MAX;
     PyObject *result;
 
     if (!PyArg_ParseTuple(args, "O|O&O&:count", &substring,
@@ -5266,8 +5266,8 @@
 unicode_find(PyUnicodeObject *self, PyObject *args)
 {
     PyUnicodeObject *substring;
-    int start = 0;
-    int end = INT_MAX;
+    Py_ssize_t start = 0;
+    Py_ssize_t end = INT_MAX;
     PyObject *result;
 
     if (!PyArg_ParseTuple(args, "O|O&O&:find", &substring,
@@ -5330,10 +5330,10 @@
 static PyObject *
 unicode_index(PyUnicodeObject *self, PyObject *args)
 {
-    int result;
+    Py_ssize_t result;
     PyUnicodeObject *substring;
-    int start = 0;
-    int end = INT_MAX;
+    Py_ssize_t start = 0;
+    Py_ssize_t end = INT_MAX;
 
     if (!PyArg_ParseTuple(args, "O|O&O&:index", &substring,
 		_PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end))
@@ -5351,7 +5351,7 @@
         PyErr_SetString(PyExc_ValueError, "substring not found");
         return NULL;
     }
-    return PyInt_FromLong(result);
+    return PyInt_FromSsize_t(result);
 }
 
 PyDoc_STRVAR(islower__doc__,
@@ -5997,8 +5997,8 @@
 unicode_rfind(PyUnicodeObject *self, PyObject *args)
 {
     PyUnicodeObject *substring;
-    int start = 0;
-    int end = INT_MAX;
+    Py_ssize_t start = 0;
+    Py_ssize_t end = INT_MAX;
     PyObject *result;
 
     if (!PyArg_ParseTuple(args, "O|O&O&:rfind", &substring,
@@ -6023,10 +6023,10 @@
 static PyObject *
 unicode_rindex(PyUnicodeObject *self, PyObject *args)
 {
-    int result;
+    Py_ssize_t result;
     PyUnicodeObject *substring;
-    int start = 0;
-    int end = INT_MAX;
+    Py_ssize_t start = 0;
+    Py_ssize_t end = INT_MAX;
 
     if (!PyArg_ParseTuple(args, "O|O&O&:rindex", &substring,
 		_PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end))
@@ -6043,7 +6043,7 @@
         PyErr_SetString(PyExc_ValueError, "substring not found");
         return NULL;
     }
-    return PyInt_FromLong(result);
+    return PyInt_FromSsize_t(result);
 }
 
 PyDoc_STRVAR(rjust__doc__,
@@ -6319,8 +6319,8 @@
 		   PyObject *args)
 {
     PyUnicodeObject *substring;
-    int start = 0;
-    int end = INT_MAX;
+    Py_ssize_t start = 0;
+    Py_ssize_t end = INT_MAX;
     PyObject *result;
 
     if (!PyArg_ParseTuple(args, "O|O&O&:startswith", &substring,
@@ -6350,8 +6350,8 @@
 		 PyObject *args)
 {
     PyUnicodeObject *substring;
-    int start = 0;
-    int end = INT_MAX;
+    Py_ssize_t start = 0;
+    Py_ssize_t end = INT_MAX;
     PyObject *result;
 
     if (!PyArg_ParseTuple(args, "O|O&O&:endswith", &substring,

Modified: python/branches/ssize_t/Python/bltinmodule.c
==============================================================================
--- python/branches/ssize_t/Python/bltinmodule.c	(original)
+++ python/branches/ssize_t/Python/bltinmodule.c	Wed Dec 21 00:59:03 2005
@@ -405,7 +405,7 @@
 	int supplied_flags = 0;
 	PyCompilerFlags cf;
 	PyObject *result = NULL, *cmd, *tmp = NULL;
-	int length;
+	Py_ssize_t length;
 
 	if (!PyArg_ParseTuple(args, "Oss|ii:compile", &cmd, &filename,
 			      &startstr, &supplied_flags, &dont_inherit))


More information about the Python-checkins mailing list