summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2000-07-09 17:41:01 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2000-07-09 17:41:01 (GMT)
commit766ccdcf18a8f31e1b23bcc4f3b34bcffe2e48d2 (patch)
tree875f7faa9cac0d1fd38d6dd1e79ff849056ff0d5 /Modules
parent6c86b99dc1e2d02cb4631df65f0726416a783087 (diff)
downloadcpython-766ccdcf18a8f31e1b23bcc4f3b34bcffe2e48d2.zip
cpython-766ccdcf18a8f31e1b23bcc4f3b34bcffe2e48d2.tar.gz
cpython-766ccdcf18a8f31e1b23bcc4f3b34bcffe2e48d2.tar.bz2
- added optional bufsize argument to new popen methods.
for the moment, this argument must be left out or set to -1 (only the default bufsize is supported, that is)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index c40060d..4d40c07 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2155,7 +2155,7 @@ posix_popen(PyObject *self, PyObject *args)
char *cmdstring;
char *mode = "r";
- if (!PyArg_ParseTuple(args, "s|s:popen", &cmdstring, &mode))
+ if (!PyArg_ParseTuple(args, "s|si:popen", &cmdstring, &mode, &bufsize))
return NULL;
s = PyTuple_New(0);
@@ -2168,6 +2168,11 @@ posix_popen(PyObject *self, PyObject *args)
} else
tm = _O_WRONLY;
+ if (bufsize != -1) {
+ PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
+ return NULL;
+ }
+
if (*(mode+1) == 't')
f = _PyPopen(cmdstring, tm | _O_TEXT , POPEN_1);
else if (*(mode+1) == 'b')
@@ -2192,7 +2197,8 @@ win32_popen2(PyObject *self, PyObject *args)
char *cmdstring;
char *mode = "t";
- if (!PyArg_ParseTuple(args, "s|s:popen2", &cmdstring, &mode))
+ int bufsize = -1;
+ if (!PyArg_ParseTuple(args, "s|si:popen2", &cmdstring, &mode, &bufsize))
return NULL;
if (*mode == 't')
@@ -2203,7 +2209,12 @@ win32_popen2(PyObject *self, PyObject *args)
} else
tm = _O_BINARY;
- f = _PyPopen(cmdstring, tm , POPEN_2);
+ if (bufsize != -1) {
+ PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
+ return NULL;
+ }
+
+ f = _PyPopen(cmdstring, tm, POPEN_2);
return f;
}
@@ -2223,7 +2234,8 @@ win32_popen3(PyObject *self, PyObject *args)
char *cmdstring;
char *mode = "t";
- if (!PyArg_ParseTuple(args, "s|s:Popen3", &cmdstring, &mode))
+ int bufsize = -1;
+ if (!PyArg_ParseTuple(args, "s|si:popen3", &cmdstring, &mode, &bufsize))
return NULL;
if (*mode == 't')
@@ -2234,6 +2246,11 @@ win32_popen3(PyObject *self, PyObject *args)
} else
tm = _O_BINARY;
+ if (bufsize != -1) {
+ PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
+ return NULL;
+ }
+
f = _PyPopen(cmdstring, tm, POPEN_3);
return f;
@@ -2254,7 +2271,8 @@ win32_popen4(PyObject *self, PyObject *args)
char *cmdstring;
char *mode = "t";
- if (!PyArg_ParseTuple(args, "s|s:popen4", &cmdstring, &mode))
+ int bufsize = -1;
+ if (!PyArg_ParseTuple(args, "s|si:popen4", &cmdstring, &mode, &bufsize))
return NULL;
if (*mode == 't')
@@ -2264,9 +2282,14 @@ win32_popen4(PyObject *self, PyObject *args)
return NULL;
} else
tm = _O_BINARY;
-
+
+ if (bufsize != -1) {
+ PyErr_SetString(PyExc_ValueError, "bufsize must be -1");
+ return NULL;
+ }
+
f = _PyPopen(cmdstring, tm , POPEN_4);
-
+
return f;
}