[Python-checkins] r42706 - python/trunk/Modules/posixmodule.c

thomas.wouters python-checkins at python.org
Wed Mar 1 02:05:18 CET 2006


Author: thomas.wouters
Date: Wed Mar  1 02:05:10 2006
New Revision: 42706

Modified:
   python/trunk/Modules/posixmodule.c
Log:

Py_ssize_t-ify.



Modified: python/trunk/Modules/posixmodule.c
==============================================================================
--- python/trunk/Modules/posixmodule.c	(original)
+++ python/trunk/Modules/posixmodule.c	Wed Mar  1 02:05:10 2006
@@ -13,6 +13,8 @@
 
 /* See also ../Dos/dosmodule.c */
 
+#define PY_SSIZE_T_CLEAN
+
 #include "Python.h"
 #include "structseq.h"
 
@@ -1759,7 +1761,7 @@
 #define MAX_PATH    CCHMAXPATH
 #endif
     char *name, *pt;
-    int len;
+    Py_ssize_t len;
     PyObject *d, *v;
     char namebuf[MAX_PATH+5];
     HDIR  hdir = 1;
@@ -1899,7 +1901,7 @@
 	/* assume encoded strings wont more than double no of chars */
 	char inbuf[MAX_PATH*2];
 	char *inbufp = inbuf;
-	int insize = sizeof(inbuf)/sizeof(inbuf[0]);
+	Py_ssize_t insize;
 	char outbuf[MAX_PATH*2];
 	char *temp;
 #ifdef Py_WIN_WIDE_FILENAMES
@@ -1919,6 +1921,7 @@
 		PyErr_Clear();
 	}
 #endif
+	/* XXX(twouters) Why use 'et#' here at all? insize isn't used */
 	if (!PyArg_ParseTuple (args, "et#:_getfullpathname",
 	                       Py_FileSystemDefaultEncoding, &inbufp,
 	                       &insize))
@@ -5590,16 +5593,18 @@
 static PyObject *
 posix_write(PyObject *self, PyObject *args)
 {
-	int fd, size;
+	int fd;
+	Py_ssize_t size;
 	char *buffer;
+
 	if (!PyArg_ParseTuple(args, "is#:write", &fd, &buffer, &size))
 		return NULL;
 	Py_BEGIN_ALLOW_THREADS
-	size = write(fd, buffer, size);
+	size = write(fd, buffer, (size_t)size);
 	Py_END_ALLOW_THREADS
 	if (size < 0)
 		return posix_error();
-	return PyInt_FromLong((long)size);
+	return PyInt_FromSsize_t(size);
 }
 
 


More information about the Python-checkins mailing list