summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index ba7ea70..f35c090 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1642,7 +1642,7 @@ posix_listdir(PyObject *self, PyObject *args)
/* MAX_PATH characters could mean a bigger encoded string */
char namebuf[MAX_PATH*2+5];
char *bufptr = namebuf;
- int len = sizeof(namebuf)/sizeof(namebuf[0]);
+ Py_ssize_t len = sizeof(namebuf)/sizeof(namebuf[0]);
#ifdef Py_WIN_WIDE_FILENAMES
/* If on wide-character-capable OS see if argument
@@ -2340,7 +2340,7 @@ posix_execv(PyObject *self, PyObject *args)
PyObject *argv;
char **argvlist;
int i, argc;
- PyObject *(*getitem)(PyObject *, int);
+ PyObject *(*getitem)(PyObject *, Py_ssize_t);
/* execv has two arguments: (path, argv), where
argv is a list or tuple of strings. */
@@ -2409,7 +2409,7 @@ posix_execve(PyObject *self, PyObject *args)
char **envlist;
PyObject *key, *val, *keys=NULL, *vals=NULL;
int i, pos, argc, envc;
- PyObject *(*getitem)(PyObject *, int);
+ PyObject *(*getitem)(PyObject *, Py_ssize_t);
int lastarg = 0;
/* execve has three arguments: (path, argv, env), where
@@ -2553,7 +2553,7 @@ posix_spawnv(PyObject *self, PyObject *args)
char **argvlist;
int mode, i, argc;
Py_intptr_t spawnval;
- PyObject *(*getitem)(PyObject *, int);
+ PyObject *(*getitem)(PyObject *, Py_ssize_t);
/* spawnv has three arguments: (mode, path, argv), where
argv is a list or tuple of strings. */
@@ -2642,7 +2642,7 @@ posix_spawnve(PyObject *self, PyObject *args)
PyObject *key, *val, *keys=NULL, *vals=NULL, *res=NULL;
int mode, i, pos, argc, envc;
Py_intptr_t spawnval;
- PyObject *(*getitem)(PyObject *, int);
+ PyObject *(*getitem)(PyObject *, Py_ssize_t);
int lastarg = 0;
/* spawnve has four arguments: (mode, path, argv, env), where
@@ -2794,7 +2794,7 @@ posix_spawnvp(PyObject *self, PyObject *args)
char **argvlist;
int mode, i, argc;
Py_intptr_t spawnval;
- PyObject *(*getitem)(PyObject *, int);
+ PyObject *(*getitem)(PyObject *, Py_ssize_t);
/* spawnvp has three arguments: (mode, path, argv), where
argv is a list or tuple of strings. */
@@ -2875,7 +2875,7 @@ posix_spawnvpe(PyObject *self, PyObject *args)
PyObject *key, *val, *keys=NULL, *vals=NULL, *res=NULL;
int mode, i, pos, argc, envc;
Py_intptr_t spawnval;
- PyObject *(*getitem)(PyObject *, int);
+ PyObject *(*getitem)(PyObject *, Py_ssize_t);
int lastarg = 0;
/* spawnvpe has four arguments: (mode, path, argv, env), where
@@ -4310,14 +4310,15 @@ _PyPopenCreateProcess(char *cmdstring,
char *s1,*s2, *s3 = " /c ";
const char *szConsoleSpawn = "w9xpopen.exe";
int i;
- int x;
+ Py_ssize_t x;
if (i = GetEnvironmentVariable("COMSPEC",NULL,0)) {
char *comshell;
s1 = (char *)alloca(i);
if (!(x = GetEnvironmentVariable("COMSPEC", s1, i)))
- return x;
+ /* x < i, so x fits into an integer */
+ return (int)x;
/* Explicitly check if we are using COMMAND.COM. If we are
* then use the w9xpopen hack.
@@ -4520,7 +4521,7 @@ _PyPopen(char *cmdstring, int mode, int n)
switch (mode & (_O_RDONLY | _O_TEXT | _O_BINARY | _O_WRONLY)) {
case _O_WRONLY | _O_TEXT:
/* Case for writing to child Stdin in text mode. */
- fd1 = _open_osfhandle((long)hChildStdinWrDup, mode);
+ fd1 = _open_osfhandle((intptr_t)hChildStdinWrDup, mode);
f1 = _fdopen(fd1, "w");
f = PyFile_FromFile(f1, cmdstring, "w", _PyPclose);
PyFile_SetBufSize(f, 0);
@@ -4531,7 +4532,7 @@ _PyPopen(char *cmdstring, int mode, int n)
case _O_RDONLY | _O_TEXT:
/* Case for reading from child Stdout in text mode. */
- fd1 = _open_osfhandle((long)hChildStdoutRdDup, mode);
+ fd1 = _open_osfhandle((intptr_t)hChildStdoutRdDup, mode);
f1 = _fdopen(fd1, "r");
f = PyFile_FromFile(f1, cmdstring, "r", _PyPclose);
PyFile_SetBufSize(f, 0);
@@ -4542,7 +4543,7 @@ _PyPopen(char *cmdstring, int mode, int n)
case _O_RDONLY | _O_BINARY:
/* Case for readinig from child Stdout in binary mode. */
- fd1 = _open_osfhandle((long)hChildStdoutRdDup, mode);
+ fd1 = _open_osfhandle((intptr_t)hChildStdoutRdDup, mode);
f1 = _fdopen(fd1, "rb");
f = PyFile_FromFile(f1, cmdstring, "rb", _PyPclose);
PyFile_SetBufSize(f, 0);
@@ -4553,7 +4554,7 @@ _PyPopen(char *cmdstring, int mode, int n)
case _O_WRONLY | _O_BINARY:
/* Case for writing to child Stdin in binary mode. */
- fd1 = _open_osfhandle((long)hChildStdinWrDup, mode);
+ fd1 = _open_osfhandle((intptr_t)hChildStdinWrDup, mode);
f1 = _fdopen(fd1, "wb");
f = PyFile_FromFile(f1, cmdstring, "wb", _PyPclose);
PyFile_SetBufSize(f, 0);
@@ -4579,9 +4580,9 @@ _PyPopen(char *cmdstring, int mode, int n)
m2 = "wb";
}
- fd1 = _open_osfhandle((long)hChildStdinWrDup, mode);
+ fd1 = _open_osfhandle((intptr_t)hChildStdinWrDup, mode);
f1 = _fdopen(fd1, m2);
- fd2 = _open_osfhandle((long)hChildStdoutRdDup, mode);
+ fd2 = _open_osfhandle((intptr_t)hChildStdoutRdDup, mode);
f2 = _fdopen(fd2, m1);
p1 = PyFile_FromFile(f1, cmdstring, m2, _PyPclose);
PyFile_SetBufSize(p1, 0);
@@ -4611,11 +4612,11 @@ _PyPopen(char *cmdstring, int mode, int n)
m2 = "wb";
}
- fd1 = _open_osfhandle((long)hChildStdinWrDup, mode);
+ fd1 = _open_osfhandle((intptr_t)hChildStdinWrDup, mode);
f1 = _fdopen(fd1, m2);
- fd2 = _open_osfhandle((long)hChildStdoutRdDup, mode);
+ fd2 = _open_osfhandle((intptr_t)hChildStdoutRdDup, mode);
f2 = _fdopen(fd2, m1);
- fd3 = _open_osfhandle((long)hChildStderrRdDup, mode);
+ fd3 = _open_osfhandle((intptr_t)hChildStderrRdDup, mode);
f3 = _fdopen(fd3, m1);
p1 = PyFile_FromFile(f1, cmdstring, m2, _PyPclose);
p2 = PyFile_FromFile(f2, cmdstring, m1, _PyPclose);
@@ -5117,8 +5118,8 @@ PyDoc_STRVAR(posix_waitpid__doc__,
static PyObject *
posix_waitpid(PyObject *self, PyObject *args)
{
- int pid, options;
- int status;
+ intptr_t pid;
+ int status, options;
if (!PyArg_ParseTuple(args, "ii:waitpid", &pid, &options))
return NULL;