]> granicus.if.org Git - python/commitdiff
Patch #788404: ignore "b" and "t" mode modifiers in posix_popen.
authorMartin v. Löwis <martin@v.loewis.de>
Fri, 31 Oct 2003 10:01:53 +0000 (10:01 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Fri, 31 Oct 2003 10:01:53 +0000 (10:01 +0000)
Fixes #703198. Backported to 2.3.

Modules/posixmodule.c

index a882023394d4c807fcbefa7ae56bd5608081acdc..9c58c9d686bc8c849f9bb21d68ed4594dc9a5c15 100644 (file)
@@ -4348,6 +4348,11 @@ posix_popen(PyObject *self, PyObject *args)
        PyObject *f;
        if (!PyArg_ParseTuple(args, "s|si:popen", &name, &mode, &bufsize))
                return NULL;
+       /* Strip mode of binary or text modifiers */
+       if (strcmp(mode, "rb") == 0 || strcmp(mode, "rt") == 0)
+               mode = "r";
+       else if (strcmp(mode, "wb") == 0 || strcmp(mode, "wt") == 0)
+               mode = "w";
        Py_BEGIN_ALLOW_THREADS
        fp = popen(name, mode);
        Py_END_ALLOW_THREADS