1313
1414/* See also ../Dos/dosmodule.c */
1515
16+ #define PY_SSIZE_T_CLEAN
17+
1618#include "Python.h"
1719#include "structseq.h"
1820
@@ -1759,7 +1761,7 @@ posix_listdir(PyObject *self, PyObject *args)
17591761#define MAX_PATH CCHMAXPATH
17601762#endif
17611763 char * name , * pt ;
1762- int len ;
1764+ Py_ssize_t len ;
17631765 PyObject * d , * v ;
17641766 char namebuf [MAX_PATH + 5 ];
17651767 HDIR hdir = 1 ;
@@ -1899,7 +1901,7 @@ posix__getfullpathname(PyObject *self, PyObject *args)
18991901 /* assume encoded strings wont more than double no of chars */
19001902 char inbuf [MAX_PATH * 2 ];
19011903 char * inbufp = inbuf ;
1902- int insize = sizeof ( inbuf )/ sizeof ( inbuf [ 0 ]) ;
1904+ Py_ssize_t insize ;
19031905 char outbuf [MAX_PATH * 2 ];
19041906 char * temp ;
19051907#ifdef Py_WIN_WIDE_FILENAMES
@@ -1919,6 +1921,7 @@ posix__getfullpathname(PyObject *self, PyObject *args)
19191921 PyErr_Clear ();
19201922 }
19211923#endif
1924+ /* XXX(twouters) Why use 'et#' here at all? insize isn't used */
19221925 if (!PyArg_ParseTuple (args , "et#:_getfullpathname" ,
19231926 Py_FileSystemDefaultEncoding , & inbufp ,
19241927 & insize ))
@@ -5590,16 +5593,18 @@ Write a string to a file descriptor.");
55905593static PyObject *
55915594posix_write (PyObject * self , PyObject * args )
55925595{
5593- int fd , size ;
5596+ int fd ;
5597+ Py_ssize_t size ;
55945598 char * buffer ;
5599+
55955600 if (!PyArg_ParseTuple (args , "is#:write" , & fd , & buffer , & size ))
55965601 return NULL ;
55975602 Py_BEGIN_ALLOW_THREADS
5598- size = write (fd , buffer , size );
5603+ size = write (fd , buffer , ( size_t ) size );
55995604 Py_END_ALLOW_THREADS
56005605 if (size < 0 )
56015606 return posix_error ();
5602- return PyInt_FromLong ( ( long ) size );
5607+ return PyInt_FromSsize_t ( size );
56035608}
56045609
56055610
0 commit comments